Google’s Flutter State Solution Secrets

Fred Grott
5 min readJan 25, 2023

Okay, the reason why you have trouble understanding state management is that it is usually explained wrong. Let’s correct that aspect.

State Starts With Stateless and Stateful Widgets

When Google implemented the Flutter’s framework render engine the second-time, it was not a native reactive implementation, in that they found when they implemented the render engine the first time that implementing reactive natively increased the time to render each frame.

Basically to get Reactive we need to have mutability via immutable elements, that happens via the framework replacing the old edition of the widget in the widget tree with the newly built version of the widget. But then the problem gets complex in that to get access to the mutable tree API, the access pattern demands that we have different API-methods to access the tree elements and updates.

This is why internally the build method involves two different things of the tree, both creating the tree and mutating the tree in the same build step. Stateless widgets are just the creation of the local tree step in the build method. While the Stateful widget has both the creation of the initial widget and mutating the state in the build method.