【发布时间】:2022-01-12 06:39:36
【问题描述】:
我是 Flutter Web 的新手,但这个错误太疯狂了,我获取 json 数据的功能是
@override
Future<List<StoryEntity>> getNewAnimation(int id) async{
print("ali");
return (json.decode(
(await http.Client().get(Uri.parse('https://hekayatname.ir/home/getanimation')))
.body)['list'] as List)
.map(
(e) => StoryEntity(
title: e['fullname'],
imagePath: e['logo_url'],
description: "e['description']",
rating: 1,
galleryImagesPath: [],
id: e['id'],
producer: e['address'],
),
).toList();
}
但我一无所获。 在网络浏览器中,我的数据是这样的,只需转到此链接 https://hekayatname.ir/home/getanimation 我把代码改成这个
Future<List<StoryEntity>> getNewAnimation(int id) async{
print("1");
final response = await http.Client().get(Uri.parse("https://hekayatname.ir/home/getaudioestory"));
if(response.statusCode == 200){
print("2");
}
else{
print("3");
print(response.statusCode);
}
}
我对 if 和 else 都一无所知 如果不工作,否则不工作....需要帮助!
【问题讨论】:
标签: json flutter rest web flutter-web