大家好,我需要你的帮助,我想显示来自api的信息,我有一个错误消息,告诉我_InternalLinkedHashMap
Future<List<FactureModel>> getUser() async {
var apiUrl = '/factures';
http.Response response = await http.get(Uri.parse(_baseUrl + apiUrl));
try {
if (response.statusCode == 200) {
List<dynamic> list = await json.decode(response.body);
print(list);
return list.map((e) => FactureModel.fromJson(e)).toList();
} else {
print("Something wrong");
return <FactureModel>[];
}
} catch (e) {
print(e);
print("Api request failled");
return <FactureModel>[];
}
//var info = rootBundle.loadString("json/data.json");
//List<dynamic> list = json.decode(await info);
//print(list);
//return Future.delayed(
//const Duration(seconds: 5), () => list.map((e) => e).toList());
}
}
将您解码后的响应直接存储到您的FractreModel而不是List中。之后,只需从旅游FractreModel返回列表。