@kevmoo suggested i file an issue report here in regards to our discussion in this thread: google/json_serializable.dart#137
To summarize, Flutter's Firebase package returns documents from Firestore collections as _InternalLinkedHashMap<dynamic, dynamic>, but Flutter's recommended json package json_serializable expects json to come in as a Map<String, dynamic>. This results in the following error:
I/flutter ( 6352): type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>' where
I/flutter ( 6352): _InternalLinkedHashMap is from dart:collection
I/flutter ( 6352): Map is from dart:core
I/flutter ( 6352): String is from dart:core
Here is an example of some code which will trigger this:
_firestore = Firestore.instance;
return _firestore.collection('favorites').where('user_id', isEqualTo: uid).getDocuments()
.then((querySnap) {
querySnap.documents.forEach((document) {
print(document.data);
Map<String, dynamic> json = document.data; //casts, but if you put breaklines through this its that _InternalLinkedHashMap<dynamic, dynamic> type
Album album = new Album.fromJson(json['favorite_albums'][0]); //Throws the type exception
});
})
.catchError((error) {
print(error);
});
Thank you!
@kevmoo suggested i file an issue report here in regards to our discussion in this thread: google/json_serializable.dart#137
To summarize, Flutter's Firebase package returns documents from Firestore collections as _InternalLinkedHashMap<dynamic, dynamic>, but Flutter's recommended json package json_serializable expects json to come in as a Map<String, dynamic>. This results in the following error:
Here is an example of some code which will trigger this:
Thank you!