Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The argument type 'Object' can't be assigned to the parameter type 'Map<String, dynamic>?

Tags:

object

flutter

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?

like image 261
Osama Mohammed Avatar asked Jan 24 '23 09:01

Osama Mohammed


2 Answers

listMakans = query.docs.map((m) => Makan.fromSnapshot(m.data() as Map<String, dynamic>?)).toList();
like image 122
Ujjwal Raijada Avatar answered Jun 04 '23 19:06

Ujjwal Raijada


Remove ? from

Makan.fromSnapshot(Map<String, dynamic>

This (m.data()!)) is the Object in the error.

like image 30
Huthaifa Muayyad Avatar answered Jun 04 '23 19:06

Huthaifa Muayyad