maintainState property

bool maintainState
final

Whether to maintain the State objects of the child subtree when it is not visible.

Keeping the state of the subtree is potentially expensive (because it means all the objects are still in memory; their resources are not released). It should only be maintained if it cannot be recreated on demand. One example of when the state would be maintained is if the child subtree contains a Navigator, since that widget maintains elaborate state that cannot be recreated on the fly.

If this property is true, an Offstage widget is used to hide the child instead of replacing it with replacement.

If this property is false, then maintainAnimation must also be false.

Dynamically changing this value may cause the current state of the subtree to be lost (and a new instance of the subtree, with new State objects, to be immediately created if visible is true).

Implementation

final bool maintainState;