sharedpreferences

How to save bool value using shared preferences

て烟熏妆下的殇ゞ 提交于 2020-12-13 11:58:25
问题 So I created a categories section in my app where you can select multiple categories by clicking on the container. The container you select changes colour. What I want to do is save the choices selected using shared preferences and display it again whenever user wants to see his selected categories. return GestureDetector( onTap: () { setState(() { if (isSelected == false) { isSelected = !isSelected; color = widget.color; print('Coming here'); } else { isSelected = false; color = Colors.white

How to save List<Object> to SharedPreferences flutter?

时光怂恿深爱的人放手 提交于 2020-12-01 09:38:19
问题 I have a list of favorite music, which I retrieve from music when the app is opened for the first time, the app gets a favorite music list from favorite. I want to save this list to shared preferences.List<Music> favoriteMusic = new List<Music>(); where music class is: class Music { final int id; final String name, size, rating, duration, img; bool favorite; Music({ this.id, this.rating, this.size, this.duration, this.name, this.img, this.favorite, }); factory Music.fromJson(Map<String,