fluttersharedpreferencesflutter-webflutter-sharedpreferenceflutter-web-browser

SharedPreferences automatically get cleared when browser closed for flutter web


SharedPreferences is automatically cleared when browser is closed for flutter web.

There is no problem when flutter web is reloaded but the problem comes when closing the browser and again when relaunched.


Solution

  • SharePrefrences works as expected in production mode, try

    flutter build web
    

    and serve files from the build/web directory (in your flutter project).