Flutter SharedPreference do not persist

后端 未结 3 1294
长情又很酷
长情又很酷 2021-01-18 11:55

I want to save user preferences using Flutter\'s SharedPreference. But the registered preferences are ALL null at new start (when app have been closed, not unis

3条回答
  •  佛祖请我去吃肉
    2021-01-18 12:35

    Hi I also faced the same issue. Did so many things. nothing helped .This may help someone.First thing ,followed this url and did the changes

    1.https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

    2.Run the command flutter upgrade

    3.Changed the shared preferences plugin in pubspec.yaml file

    shared_preferences: ">=0.5.10 <2.0.0"

    4.Deleted the pub cache from installed flutter location

    C:\Users\myuser\AppData\Local\Pub\Cache\hosted\pub.dartlang.org

    5.flutter build apk --debug

    6.flutter build apk --profile

    7.flutter run --release (if I run directly this command its throwing error like debug.jar not found , so I ran command 5 and 6 )

    Command 7 is for - To Verify whether its working perfectly in release mode.

    Finally I tried to generate app build without shrinking the code. then it worked

    flutter build apk --no-shrink flutter build appbundle --no-shrink

提交回复
热议问题