Issue
I try to persist an Event data type in my project
loadEventList() async {
await _init();
final _ev = _prefs.getStringList('eventList');
List<Event> listToEvent = _ev as List<Event>;
return _events = listToEvent;
}
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'List<String>' is not a subtype of type 'List<Event>' in type cast
Can somebody help me find a way to convert my list into an event list?
Solution
I think using the map function would help
_events = _ev.map((String element){return Event(param);});
Answered By - Algidaq Elemgdadi
Answer Checked By - Clifford M. (JavaFixing Volunteer)