This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split root widget to fix wrong usage (#20)
The current widget `App` uses two nested `FutureBuilder`s in a wrong way: The provided future should not be constructed inside the build method. As the [documentation](https://api.flutter.dev/flutter/widgets/FutureBuilder-class.html#managing-the-future) puts it: > The future must have been obtained earlier, e.g. during State.initState, State.didUpdateWidget, or State.didChangeDependencies. It must not be created during the State.build or StatelessWidget.build method call when constructing the FutureBuilder. If the future is created at the same time as the FutureBuilder, then every time the FutureBuilder's parent is rebuilt, the asynchronous task will be restarted. This behavior has been observed during development as flickering and crashing due to duplicate network activation. With this change the two `FutureBuilder`s now live in their own separate stateful widgets where the futures are constructed by their respective `initState` methods. This change has the furtunate side effect of making the original widget much simpler and easier to understand. --------- Co-authored-by: Søren Schwartz <[email protected]>
- Loading branch information
Showing
1 changed file
with
93 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters