Unhandled Exception: type '_InternalLinkedHashMap' is not a subtype of type
How to resolve the error
Unhandled Exception: type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type
You may faced it when try to parse json data in Flutter
var dataSnapShot = await _mDBRef.child(FireDBConstants.PATH_CATEGORY).once();
List<SubCategory> list = [];
dataSnapShot.value.forEach((key, value) {
list.add(SubCategory.fromMap(Map<String, dynamic>.from(value)));
});
Above example is of Firebase Realtime Database response handle. The solution is
Map<String, dynamic>.from(value)If there is nested model use as belowelements = ElementModel.fromMap(Map<String,dynamic>.from(json["elements"])),Give it a try and let me know if you facing any issue.Thanks
Comments
Post a Comment