Does anybody knows how to fix this error?
Error: Can't use the default List constructor.
Future<List<EventModel>> getTaskList() async {
var taskMapList = await getTasks();
//var taskList = List<EventModel>();
var taskList = new List<EventModel>();
for (Map map in taskMapList) {
taskList.add(EventModel.fromMap(map));
}
return taskList;
}
CodePudding user response:
Please use the below code:
Future<List<EventModel>> getTaskList() async {
var taskMapList = await getTasks();
var taskList = <EventModel>[];
for (Map map in taskMapList) {
taskList.add(EventModel.fromMap(map));
}
return taskList;
}