【发布时间】:2019-10-04 21:42:30
【问题描述】:
我在下面有 JSON 文件。
Data.json
[{
"rownum": 1,
"total": 10.99793271,
"total2": 106.65666751,
}, {
"rownum": 2,
"total": 10.99793271,
"total2": 106.65666751,
}]
还有class Item和List
List <Item> item;
class Item {
String row;
String total;
String total2;
Student({this.row, this.total, this.total2});
}
我如何从data.json 和add 获取数据到initState() 上的List <Item> item?
这样
class MyAppState extends State<MyApp> {
@override
void initState() {
Future<String> _loadAStudentAsset() async {
return await rootBundle.loadString('assets/data.json');
}
//....some code to add value into list
super.initState();
}
【问题讨论】: