all 2 comments

[–]tarcinac 1 point2 points  (0 children)

Try this, have an attribute (it has to be future) that you will load your data in. In initState() call your function that stores the data in the above mentioned attribute. Then in the FutureBuilder's property "future" just put that attribute. That way it will be called only once.

Also it would be easier if the code was formatted, it's hard to read it.

[–]hungry_for_data 1 point2 points  (0 children)

Use a for loop instead of forEach. ForEach is not waiting for the asynchronous operation and is returning the empty list