pub trait RenderObjectWidget: Debug + 'static {
type RenderObject: RenderObject;
// Required method
fn create_render_object(
&self,
app: &mut App,
context: BuildContext,
) -> AnyRenderObject;
// Provided methods
fn key(&self) -> Option<&KeyRef> { ... }
fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
) { ... }
fn to_string_short(&self) -> String { ... }
fn debug_check_constructor(&self) { ... }
fn debug_visit_onstage_children(
&self,
app: &App,
children: &[AnyElement],
visitor: &mut dyn FnMut(AnyElement),
) { ... }
fn update_render_object(
&self,
app: &mut App,
context: BuildContext,
render_object: RenderHandle<Self::RenderObject>,
) { ... }
fn did_unmount_render_object(
&self,
app: &mut App,
render_object: RenderHandle<Self::RenderObject>,
) { ... }
}Expand description
The parts of a RenderObjectWidget every kind shares: the render object it creates and
updates. Dart’s covariant RenderObject renderObject parameters are typed through
RenderObject.
Required Associated Types§
Sourcetype RenderObject: RenderObject
type RenderObject: RenderObject
The render object this widget creates; Dart’s covariant RenderObject parameter type.
Required Methods§
Sourcefn create_render_object(
&self,
app: &mut App,
context: BuildContext,
) -> AnyRenderObject
fn create_render_object( &self, app: &mut App, context: BuildContext, ) -> AnyRenderObject
Creates an instance of the RenderObject class that this widget represents, using the
configuration described by this widget.
This method should not do anything with the children of the render object. That
should instead be handled by the method that overrides RenderObjectElement.mount
in the object rendered by this object’s create_element method.
Returns the type-erased handle (handle.as_object()), which is what the element tree holds;
update_render_object gets the typed handle back.
Provided Methods§
Sourcefn key(&self) -> Option<&KeyRef>
fn key(&self) -> Option<&KeyRef>
See Widget::key.
Sourcefn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
Dart’s 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.
Sourcefn to_string_short(&self) -> String
fn to_string_short(&self) -> String
Dart’s toStringShort, for a widget that names itself apart from its type, as
SizedBox.expand does; see Widget::to_string_short.
Sourcefn debug_visit_onstage_children(
&self,
app: &App,
children: &[AnyElement],
visitor: &mut dyn FnMut(AnyElement),
)
fn debug_visit_onstage_children( &self, app: &App, children: &[AnyElement], visitor: &mut dyn FnMut(AnyElement), )
Dart’s debugVisitOnstageChildren of the element this widget makes, for a widget whose
Dart element subclass overrides it only to hide children (_OffstageElement,
_IndexedStackElement): calls visitor for each of children, in order, that is
onstage. Waft’s generic single- and multi-child elements stand in for those subclasses
and ask their widget here; an element of a widget’s own overrides
Element::debug_visit_onstage_children instead.
Sourcefn update_render_object(
&self,
app: &mut App,
context: BuildContext,
render_object: RenderHandle<Self::RenderObject>,
)
fn update_render_object( &self, app: &mut App, context: BuildContext, render_object: RenderHandle<Self::RenderObject>, )
Copies the configuration described by this widget to the given render object, which
will be of the same type as returned by this object’s
create_render_object.
This method should not do anything to update the children of the render object. That
should instead be handled by the method that overrides RenderObjectElement.update
in the object rendered by this object’s create_element method.
Sourcefn did_unmount_render_object(
&self,
app: &mut App,
render_object: RenderHandle<Self::RenderObject>,
)
fn did_unmount_render_object( &self, app: &mut App, render_object: RenderHandle<Self::RenderObject>, )
A render object previously associated with this widget has been removed from the tree.
The given RenderObject will be of the same type as returned by this object’s
create_render_object.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".