I am trying to use this code. But, for some reason I get an error that I do not fit into the range. It's just that several elements can come from the server, so I can't use hardcode and specify values like 1,2 and so on...
Here is the error I am getting - RangeError (index): Invalid value: Only valid value is 0: 1
And here is my code -
child: Text(' name - ${catalogDrawer[index].one[index].name}'),
of course it's wrapped in ListView.builder Essence of the question. How can I use an index multiple times?
CodePudding user response:
As the error said the only valid value for one
is 0
, and your listView items is base on catalogDrawer's length
. So you can't use catalogDrawer's index
on one's items
. you either can use an other listView and use that index to show one's items or if you sure it only have one value use catalogDrawer[index].one.first.name
.