'_CastError (type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>' in type cast) trying to read data fron json file
this is my modal
class CelebDataModal {
String ? name;
String? image;
CelebDataModal (
this.name,
this.image
);
CelebDataModal.fromJson(Map<String, dynamic> json){
name = json["name"] ;
image = json["image"];
}
}
trying to get data from json file
Future<List<CelebDataModal>> readJsonData() async{
final jsondata = await rootBundle.loadString('jsonfile/data.json');
final list = json.decode(jsondata) as List<dynamic>;
return list.map((e) => CelebDataModal.fromJson(e)).toList();
}
}
_
CastError (type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List' in type cast)
what could be the reason?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
