Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Shared Preferences misplugin

i do same exactly as youtube says but in the end i got this error, do you know what is the problem ?

im using flutter 2.8.1 shared_preferences: ^2.0.13

this is the code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

 class _AppHomeState extends State<AppHome> {
 final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
        Future loadData() async {
            final SharedPreferences prefs = await _prefs;
            var stringSet = await prefs.getString('sets');
            List setList = jsonDecode(stringSet!);
            for (var sets in setList) {
              c.setList.add(SetModel().fromJson(sets));
            }
          }
        
          Future saveData() async {
            final SharedPreferences prefs = await _prefs;
            List items = c.setList.map((e) => e.toJson()).toList();
            prefs.setString('sets', jsonEncode(items));
          }

enter image description here

>Solution :

try running

flutter clean

see issue here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading