RestorationScope class Null safety

Creates a new scope for restoration IDs used by descendant widgets to claim RestorationBuckets.

A restoration scope inserts a RestorationBucket into the widget tree, which descendant widgets can access via RestorationScope.of. It is uncommon for descendants to directly store data in this bucket. Instead, descendant widgets should consider storing their own restoration data in a child bucket claimed with RestorationBucket.claimChild from the bucket provided by this scope.

The bucket inserted into the widget tree by this scope has been claimed from the surrounding RestorationScope using the provided restorationId. If the RestorationScope is moved to a different part of the widget tree under a different RestorationScope, the bucket owned by this scope with all its children and the data contained in them is moved to the new scope as well.

This widget will not make a RestorationBucket available to descendants if restorationId is null or when there is no surrounding restoration scope to claim a bucket from. In this case, descendant widgets invoking RestorationScope.of will receive null as a return value indicating that no bucket is available for storing restoration data. This will turn off state restoration for the widget subtree.

See also:

Inheritance

Constructors

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

Properties

child Widget
The widget below this widget in the tree.
final
hashCode int
The hash code for this object.
nonVirtual">@nonVirtualread-onlyinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
restorationId String?
The restoration ID used by this widget to obtain a child bucket from the surrounding RestorationScope.
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

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

Operators

operator ==(Object other) bool
The equality operator.
nonVirtual">@nonVirtualinherited

Static Methods

of(BuildContext context) RestorationBucket?
Returns the RestorationBucket inserted into the widget tree by the closest ancestor RestorationScope of context.