So I have a FutureBuilder that calls different methods depending on what button is pressed.
child: FutureBuilder(
future: buffetPressed
? API().getPackages(widget.restaurant.id)
: API().getFoodItems(widget.restaurant.id),
Which returns a Listview.Builder
return ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data.length,
The problem is snapshot.data.length is different for each method as each api call returns different data. Everything else updates in the list (names, etc) but the length does not update causing RangeError (index): Invalid value: not in inclusive range. Which I understand is from the itemCount being wrong. Is there a way to update the itemcount when the button is pressed? I'm fairly new and I can't figure it out.
snapshot.datais the output ofAPI().getPackagesorAPI().getFoodItems? - John Joesnapshot.dataare depends on the output of the two. - John JoeInvalid value: not in inclusive rangeerror. - John Joe