我遇到错误
'_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>'
代码:
Future<List<Data>> fetchData() async {
http.Response response = await http.get(url);
List responseJson = json.decode(response.body);
return responseJson.map((m) => new Data.fromJson(m)).toList();
}
和来自杰森:
factory Data.fromJson(Map<String, dynamic> json) {
return Data(
name: json['data']['title'],
des: json['data']['des'],
);
}
我这样称呼它:
var datas = Provider.of<Data>(context).fetchData() as List<Data>;