pub struct RootRestorationScope {
pub key: Option<KeyRef>,
pub child: WidgetRef,
pub restoration_id: Option<String>,
}Expand description
Inserts a child bucket of RestorationManager::root_bucket 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 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::root_bucket) using the
provided restoration_id and inserts that bucket into the widget
tree where descendants may access it via RestorationScope::of. If the
RootRestorationScope finds a non-None 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
restoration_id is not None and RestorationManager is able to
provide a root bucket. In other words, it will force-enable state restoration for the subtree
if restoration_id is not None.
If restoration_id is None, no bucket is made available to
descendants, which effectively turns off state restoration for this subtree.
See also:
RestorationScope, which inserts a bucket obtained from a surrounding restoration scope into the widget tree and makes it accessible for descendants viaRestorationScope::of.UnmanagedRestorationScope, which inserts a providedRestorationBucketinto the widget tree and makes it accessible for descendants viaRestorationScope::of.RestorationMixin, which may be used inStateobjects to manage the restoration data of aStatefulWidgetinstead of manually interacting withRestorationScopes andRestorationBuckets.RestorationManager, which describes the basic concepts of state restoration.
Fields§
§key: Option<KeyRef>See StatefulWidget::key.
child: WidgetRefThe widget below this widget in the tree.
restoration_id: Option<String>The restoration ID used to identify the child bucket that this widget will insert into the tree.
If this is None, no bucket is made available to descendants and state restoration for
the subtree is essentially turned off.
Implementations§
Source§impl RootRestorationScope
impl RootRestorationScope
Sourcepub fn new<K>(
restoration_id: Option<String>,
child: impl IntoWidget<K>,
) -> RootRestorationScope
pub fn new<K>( restoration_id: Option<String>, child: impl IntoWidget<K>, ) -> RootRestorationScope
Creates a RootRestorationScope.
Providing None as the restoration_id turns off state restoration for the child and
its descendants.
Sourcepub fn key(self, key: KeyRef) -> RootRestorationScope
pub fn key(self, key: KeyRef) -> RootRestorationScope
Dart RootRestorationScope(key:).
Trait Implementations§
Source§impl Debug for RootRestorationScope
impl Debug for RootRestorationScope
Source§impl StatefulWidget for RootRestorationScope
impl StatefulWidget for RootRestorationScope
Source§type State = RootRestorationScopeState
type State = RootRestorationScopeState
Source§fn create_state(&self) -> RootRestorationScopeState
fn create_state(&self) -> RootRestorationScopeState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl !RefUnwindSafe for RootRestorationScope
impl !Send for RootRestorationScope
impl !Sync for RootRestorationScope
impl !UnwindSafe for RootRestorationScope
impl Forget for RootRestorationScope
impl Freeze for RootRestorationScope
impl Move for RootRestorationScope
impl Unpin for RootRestorationScope
impl UnsafeUnpin for RootRestorationScopewhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.