Skip to main content

StatefulWidget

Trait StatefulWidget 

Source
pub trait StatefulWidget: 'static {
    type State: State<Widget = Self>;

    // Required method
    fn create_state(&self) -> Self::State;

    // Provided method
    fn into_widget(self) -> Component
       where Self: Sized { ... }
}
Expand description

A widget whose State outlives the rebuilds. The widget is only the configuration: it is made again on every rebuild, and the state is what is kept.

Required Associated Types§

Source

type State: State<Widget = Self>

What is kept.

Required Methods§

Source

fn create_state(&self) -> Self::State

Makes the state, once, when the widget first enters the tree.

Provided Methods§

Source

fn into_widget(self) -> Component
where Self: Sized,

This component as a widget.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§