[英]I can't get the complex json data to the listview in flutter
https://paste.ubuntu.com/p/9FwNMbDxKs/这是我的 json 数据
https://paste.ubuntu.com/p/yycQdpsHHM/这是我的 model
https://paste.ubuntu.com/p/wKgnfXy9tF/ this is my function in apiservice till now everything is fine but when i try to reach my json data like:
List<Menu> menuler = List<Menu>();
@override
Widget build(BuildContext context) {
islemDonus = IslemDonus();
islemDonus.anaMenuListeyiAl().then((value) {
menuler.add(value[0].anagrupBaslik.toString());
for (var i = 0; i < value.length; i++) {
menuler.add(value[i].anagrupBaslik.toString());
}
});
它说:
The argument type 'String' can't be assigned to the parameter type 'Menu'.
但是来自 json 数据的值是 Menu ,如您所见,我创建了我的列表,为什么会这样?,
toString
方法返回一个String
,所以在你的menuler.add(value[i].anagrupBaslik.toString());
您显然正在将String
添加到Menu
列表中。
Pyth0nGh057 的答案是正确的,但这可能会帮助您解决问题: https://medium.com/flutter-community/parsing-complex-json-in-flutter-747c46655f51
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.