pub trait StatelessWidget: 'static {
// Required method
fn build(&self, cx: &BuildContext<'_>) -> Box<dyn Widget>;
// Provided method
fn into_widget(self) -> Component
where Self: Sized { ... }
}Expand description
A widget with nothing to remember: it says what it looks like from what it is configured with, and from nothing else.
Any Fn(&BuildContext) -> Box<dyn Widget> is one, which is how a function becomes a
component — and, with hooks, one that remembers.
Required Methods§
Sourcefn build(&self, cx: &BuildContext<'_>) -> Box<dyn Widget>
fn build(&self, cx: &BuildContext<'_>) -> Box<dyn Widget>
The widget this one stands for. Called whenever the tree is rebuilt.
Provided Methods§
Sourcefn into_widget(self) -> Componentwhere
Self: Sized,
fn into_widget(self) -> Componentwhere
Self: Sized,
This component as a widget: what goes in a column![..], a Scaffold’s body, a
route’s page.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".