The argument type 'Object' can't be assigned to the parameter type 'Map<String, dynamic>?
2,428
Solution 1
listMakans = query.docs.map((m) => Makan.fromSnapshot(m.data() as Map<String, dynamic>?)).toList();
Solution 2
Remove ?
from
Makan.fromSnapshot(Map<String, dynamic>
This (m.data()!))
is the Object in the error.
Author by
Osama Mohammed
Updated on December 29, 2022Comments
-
Osama Mohammed over 1 year
i have encountered this error :
The argument type 'Object' can't be assigned to the parameter type 'Map<String, dynamic>?
in this line of code :
listMakans = query.docs.map((m) => Makan.fromSnapshot(m.data()!)).toList();
and here is the code for (Makan.fromSnapshot):
Makan.fromSnapshot(Map<String, dynamic>? snapshot) : id = snapshot!['id'], owner = snapshot['owner'], category = snapshot['category'], hobby = snapshot['hobby'], business = snapshot['business'], title = snapshot['title'], details = snapshot['details'], latlng = snapshot['latlng'], from = snapshot['from'].toDate(), to = snapshot['to'].toDate(), created = snapshot['created'].toDate(), updated = snapshot['updated'].toDate();
i didn't understand where the Object here?
-
Osama Mohammed almost 3 yearsbut i tried to delete it, and same problem, the code was work without problems, but after upgrade some plugins, i face this problem
-
Huthaifa Muayyad almost 3 yearsNo, go to your factory Makan.fromSnapshot and remove the question mark.
-
Huthaifa Muayyad almost 3 yearsRemoving the question mark from your method should change the error. It could be from someplace else.