0

I am getting a flutter Range error despite putting a child count on the widget. This is the initial call for getting the elements from the logic.

The logic works fine and it maps properly but it's showing a range error despite all the length's being finite. It works fine if I put it in a list view but I need the entire screen scrollable hence the need for a sliver List builder

2 Answers2

0

change this

if (res == null) {
       return;
 }

to

 if (res == null) {
    // return empty list not null ( since null has no lenght) 
   return <MenuItem>[];
 }
Loïc Fonkam
  • 2,284
  • 11
  • 25
  • 1
    I found the solution. The number of items in menuCat and menuData is different. So according to the Sliver builder since the headings have a length of 4 and the count is 28 hence the issue. All I had to do was put menuCat.length in the child count – Vedant Yogesh Mar 29 '20 at 18:56
0

The answer is that among the two different lengths in StickyHeader, we must pick the one less in number i.e. the menuCat.length(Header length) in the child count.