Flutter: possible to wait for sibling widgets to finish building?

Viewed 512

The title probably says it all. My scenario is that I have different widgets waiting for firebase data to build their contents. The last widget should wait for others to complete and do some computation based on the retrieved data from Firebase. Is this possible at all?

I have tried ValueListenableBuilder which gave me this error:

The following assertion was thrown while dispatching notifications for ValueNotifier: setState() or markNeedsBuild() called during build.

1 Answers

Inside the build method use the FutureBuilder widget which is used for operations. The FutureBuilder widget contains a property called future which takes a method that returns a future.

Inside that method you can execute the first query using await and use the result of the first query to execute the second query.

Related