Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
792 views
in Technique[技术] by (71.8m points)

dart - Can i put List into SharedPreferences in Flutter?

Can I put ArrayList or List object to SharedPreferences in Flutter? Cause I just realized that flutter haven't gson in their dart

So..i want to save like favorite books by tapping star icon, and when I tap that, that books will be saved in sharedPreferences.

and I can see the list of my favorite books.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Save:

prefs.setStringList('key', yourList);

Retrieve:

var yourList = prefs.getStringList('key');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...