My data is stored in nested form like
Collection->Document->Collection->Document->Collection->Document
I am fetching data using stream builder in flutter. My aim is to create an instance of a class whose attributes are distributed in all the three layers of collection/documents.
After reading second layer, my function return the class object having partial values null, and shows the error on screen, but after some time it prints the values in the last layer.
I can not use the async/ await functionality here because of the stream builder.
I tried to make the nested function but no again.
I have tried sleep() function as well.
As you can below, After reading productVariant Snapshots, it skips the foreach loop and creates an instance of Order and return. However I'm also printing the values and they got print after the return command execute.
Thanks for the answers, but I figured out the solution.
I used the nested FutureBuilders which returns promised widgets.
I modified my Order instance by updating variables with widgets.
Before
StreamBuilder -> Fetching Collections and Documents
After
StreamBuilder -> FutureBuilder to Fetch Collection/Document ->FutureBuilder - >To fetch inner Collection/Document