Search code examples
flutterdartflutter-layoutflutter-futurebuilder

Manually adding items to futurebuilder in flutter


I am making a shopping app. I have an api which sends 11 tabs with many products in each tab. In my code, i am using futurebuilder to show that data. I want to add a tab 'All' which shows all the products in all tabs under a single tab. But when i manually add the 12th tab, the futurebuilder throws range error.

RangeError (index): Invalid value: Not in inclusive range 0..10: 11

I am guessing its because futurebuilder automatically takes number of tabs based on the number of items in snapshot. I followed this example for the body of the 'all' tab. I am wondering if it is possible to manually add tab and products in futurebuilder? If yes, how do i go about doing that?


Solution

  • For somebody else who might want to know this, you can just remove the future builder and return something like listview builder or whatever you need. Here is a very helpful link.