'_InternalLinkedHashMap <String,dynamic>'不是'List <dynamic>'类型的子类型

时间:2019-12-02 10:34:46

标签: android ios flutter

我遇到错误

'_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>;

0 个答案:

没有答案