of method Null safety

RestorationBucket? of(
  1. BuildContext context
)

Returns the RestorationBucket inserted into the widget tree by the closest ancestor RestorationScope of context.

To avoid accidentally overwriting data already stored in the bucket by its owner, data should not be stored directly in the bucket returned by this method. Instead, consider claiming a child bucket from the returned bucket (via RestorationBucket.claimChild) and store the restoration data in that child.

This method returns null if state restoration is turned off for this subtree.

Implementation

static RestorationBucket? of(BuildContext context) {
  return context.dependOnInheritedWidgetOfExactType<UnmanagedRestorationScope>()?.bucket;
}