[英]I can't get the complex json data to the listview in flutter
https://paste.ubuntu.com/p/9FwNMbDxKs/ this is my json data https://paste.ubuntu.com/p/9FwNMbDxKs/这是我的 json 数据
https://paste.ubuntu.com/p/yycQdpsHHM/ this is my model 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: 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());
}
});
it says:它说:
The argument type 'String' can't be assigned to the parameter type 'Menu'.
but the value which comes from json data is Menu and as you can see i created my List why it is happening?,但是来自 json 数据的值是 Menu ,如您所见,我创建了我的列表,为什么会这样?,
The method toString
returns a String
, so in your menuler.add(value[i].anagrupBaslik.toString());
toString
方法返回一个String
,所以在你的menuler.add(value[i].anagrupBaslik.toString());
you are clearly adding a String
into a Menu
list.您显然正在将
String
添加到Menu
列表中。
Pyth0nGh057's answer is correct, but this might help your problem: https://medium.com/flutter-community/parsing-complex-json-in-flutter-747c46655f51 Pyth0nGh057 的答案是正确的,但这可能会帮助您解决问题: https://medium.com/flutter-community/parsing-complex-json-in-flutter-747c46655f51
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.