maintainState property

bool maintainState
final

Whether to maintain the State objects of the sliver 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 sliver subtree contains a Navigator, since that widget maintains elaborate state that cannot be recreated on the fly.

If this property is true, a SliverOffstage widget is used to hide the sliver instead of replacing it with replacementSliver.

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;