【发布时间】:2021-09-13 06:55:03
【问题描述】:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Products',
),
),
body: Center(
child: FutureBuilder(
future: fetchPhotos(),
builder: (ctx, snapShot) {
if (snapShot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
} else {
return ListView.builder(
itemBuilder: (context, index) {
return ListTile(
leading: CircleAvatar(
backgroundColor: Colors.red,
),
title: Text(snapShot.data["table"][index]["name"]),
subtitle: Text(
"price: ${snapShot.data["table"][index]["class_id"]}"),
);
},
);
}
},
),
),
);
}
我应该在 itemCount 中添加什么以避免显示错误:小部件库 RangeError (index) 捕获的异常:无效值:不在包含范围 0..35:36 中
【问题讨论】:
标签: flutter dart flutter-http