I have a error "A value of type ‘OutletListModel’ can’t be assigned to a variable of type ‘List?’"
so how to resolve this error
List<OutletListModel>? selectedData;
3
You can add item on list with myList.add(YouItem). if you like to replace , you can do myList = [.... ], but in this case myList shouldn’t be final.
myList.add(YouItem)
myList = [.... ]
myList
For your case, you can do
final newItem = OutletModel.from(.....); selectedData.add(newItem);
change the code line where the error appears with:
selectedData = [OutletListModel.fromJson(value.toJson())];
because selectedData expects an Array of OutletListModel;
selectedData
OutletListModel
OutletListModel.fromjson(value.tojson()).tolist()
make the response as list to assign
Click here to cancel reply.
3
Answers
You can add item on list with
myList.add(YouItem)
. if you like to replace , you can domyList = [.... ]
, but in this casemyList
shouldn’t be final.For your case, you can do
change the code line where the error appears with:
because
selectedData
expects an Array ofOutletListModel
;make the response as list to assign