Flutter Cloud Firestore Map<String, dynamic> error
I believe this is because the Map returned from Firebase is not a Map<String, dynamic>
but instead Map<dynamic, dynamic>
.
See https://github.com/flutter/flutter/issues/17417 for a related issue.
Use Map<String, dynamic>.from ( mapFromFirestore )
. This creates a new Map<String, dynamic>
from the contents of mapFromFirestore
, throwing an error if it finds a key that isn't a String
.
I too had this problem and fixed it with --
Map<String, dynamic> var = {'item': 0, 'name': 'John'}
instead of Map unspecified.
Map var = {'item': 0, 'name': 'John'}