I'm making a Flutter app for fuel expenses tracking. I have a simple object:
class Entry {
double _fuel;
double _money;
double _distance;
Entry(this._fuel, this._money, this.distance);
Entry.fromJson(Map<String, dynamic> json) => Entry (json['fuel'], json['money'], json['distance']);
Map<String, dynamic> toJson() => {'fuel':_fuel, 'money':_money, 'distance':_distance};
}
Whenever I refill my tank I want to make a new entry and to keep all of them virtually forever. In the app I have a List<Entry> entries, but I couldn't find a way to save that list in SharedPreferences. There is only a method which accepts a list of Strings. Should I create a new List<String> by iterating through my List<Entries> and serializing each entry, and then saving that list to the SharedPreferences or is there an easier way? And when I want to read from SharedPreferences, how can I recreate my list?
Update: Of course, I also need to be able to delete a particular entry from the list.
Thanks.