我的forEach有问题,dataList为null 这是我的代码:
Future<List<Widget>> createList()async{
List<Widget> items = new List<Widget>();
String dataString = await DefaultAssetBundle.of(context).loadString("assets/data.json");
List<dynamic> dataJSON = jsonDecode(dataString);
dataJSON.forEach((object) {
String finalString="";
List<dynamic> dataList = object["placeItems"];
dataList.forEach((item) {
finalString = finalString + item + " | ";
});
这是我的json数据:
[
{
"placeImage":"images/fish2.jpg",
"placeName":"Ikan 2",
"placeItem":["fish, crab, seafood"],
"minOrder":20
},
]