RootRestorationScope class Null safety

Inserts a child bucket of RestorationManager.rootBucket into the widget tree and makes it available to descendants via RestorationScope.of.

This widget is usually used near the root of the widget tree to enable the state restoration functionality for the application. For all other use cases, consider using a regular RestorationScope instead.

The root restoration bucket can only be retrieved asynchronously from the RestorationManager. To ensure that the provided child has its restoration data available the first time it builds, the RootRestorationScope will build an empty Container instead of the actual child until the root bucket is available. To hide the empty container from the eyes of users, the RootRestorationScope also delays rendering the first frame while the container is shown. On platforms that show a splash screen on app launch the splash screen is kept up (hiding the empty container) until the bucket is available and the child is ready to be build.

The exact behavior of this widget depends on its ancestors: When the RootRestorationScope does not find an ancestor restoration bucket via RestorationScope.of it will claim a child bucket from the root restoration bucket (RestorationManager.rootBucket) using the provided restorationId and inserts that bucket into the widget tree where descendants may access it via RestorationScope.of. If the RootRestorationScope finds a non-null ancestor restoration bucket via RestorationScope.of it will behave like a regular RestorationScope instead: It will claim a child bucket from that ancestor and insert that child into the widget tree.

Unlike the RestorationScope widget, the RootRestorationScope will guarantee that descendants have a bucket available for storing restoration data as long as restorationId is not null and RestorationManager is able to provide a root bucket. In other words, it will force-enable state restoration for the subtree if restorationId is not null.

If restorationId is null, no bucket is made available to descendants, which effectively turns off state restoration for this subtree.

See also:



RootRestorationScope({Key? key, required String? restorationId, required Widget child})
Creates a RootRestorationScope.


child Widget
The widget below this widget in the tree.
hashCode int
The hash code for this object.
key Key?
Controls how one widget replaces another widget in the tree.
restorationId String?
The restoration ID used to identify the child bucket that this widget will insert into the tree.
runtimeType Type
A representation of the runtime type of the object.


createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
createState() State<RootRestorationScope>
Creates the mutable state for this widget at a given location in the tree.
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
toString({DiagnosticLevel minLevel =}) String
A string representation of this object.
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
toStringShort() String
A short, textual description of this widget.


operator ==(Object other) bool
The equality operator.