pub trait Element: Sized + 'static {
const IS_RENDER_OBJECT_ELEMENT: bool = false;
const IS_PARENT_DATA_ELEMENT: bool = false;
const IS_INHERITED_ELEMENT: bool = false;
Show 36 methods
// Required methods
fn element_data(self: Handle<Self>, app: &App) -> &ElementData;
fn element_data_mut(self: Handle<Self>, app: &mut App) -> &mut ElementData;
// Provided methods
fn as_element(self: Handle<Self>) -> AnyElement { ... }
fn visit_children(
self: Handle<Self>,
app: &App,
visitor: &mut dyn FnMut(AnyElement),
) { ... }
fn debug_visit_onstage_children(
self: Handle<Self>,
app: &App,
visitor: &mut dyn FnMut(AnyElement),
) { ... }
fn render_object_attaching_child(
self: Handle<Self>,
app: &App,
) -> Option<AnyElement> { ... }
fn mount(
self: Handle<Self>,
app: &mut App,
parent: Option<AnyElement>,
new_slot: Option<Slot>,
) { ... }
fn update(self: Handle<Self>, app: &mut App, new_widget: WidgetRef) { ... }
fn update_slot(self: Handle<Self>, app: &mut App, new_slot: Option<Slot>) { ... }
fn attach_render_object(
self: Handle<Self>,
app: &mut App,
new_slot: Option<Slot>,
) { ... }
fn detach_render_object(self: Handle<Self>, app: &mut App) { ... }
fn forget_child(self: Handle<Self>, app: &mut App, child: AnyElement) { ... }
fn activate(self: Handle<Self>, app: &mut App) { ... }
fn deactivate(self: Handle<Self>, app: &mut App) { ... }
fn debug_deactivated(self: Handle<Self>, app: &mut App) { ... }
fn unmount(self: Handle<Self>, app: &mut App) { ... }
fn perform_rebuild(self: Handle<Self>, app: &mut App) { ... }
fn did_change_dependencies(self: Handle<Self>, app: &mut App) { ... }
fn update_inheritance(self: Handle<Self>, app: &mut App) { ... }
fn attach_notification_tree(self: Handle<Self>, app: &mut App) { ... }
fn build_scope(self: Handle<Self>, app: &App) -> Handle<BuildScope> { ... }
fn mark_needs_build(self: Handle<Self>, app: &mut App) { ... }
fn on_notification(
self: Handle<Self>,
app: &mut App,
notification: &dyn Notification,
) -> bool { ... }
fn debug_expects_render_object_for_slot(
self: Handle<Self>,
app: &App,
slot: Option<&Slot>,
) -> bool { ... }
fn render_object(self: Handle<Self>, app: &App) -> Option<AnyRenderObject> { ... }
fn debug_doing_build(self: Handle<Self>, app: &App) -> bool { ... }
fn insert_render_object_child(
self: Handle<Self>,
app: &mut App,
child: AnyRenderObject,
slot: Option<Slot>,
) { ... }
fn move_render_object_child(
self: Handle<Self>,
app: &mut App,
child: AnyRenderObject,
old_slot: Option<Slot>,
new_slot: Option<Slot>,
) { ... }
fn remove_render_object_child(
self: Handle<Self>,
app: &mut App,
child: AnyRenderObject,
slot: Option<Slot>,
) { ... }
fn update_parent_data(
self: Handle<Self>,
app: &mut App,
parent_data_element: AnyElement,
) { ... }
fn apply_parent_data(
self: Handle<Self>,
app: &mut App,
render_object: AnyRenderObject,
) -> bool { ... }
fn update_dependencies(
self: Handle<Self>,
app: &mut App,
dependent: AnyElement,
aspect: Option<Rc<dyn Any>>,
) { ... }
fn remove_dependent(
self: Handle<Self>,
app: &mut App,
dependent: AnyElement,
) { ... }
fn state_handle_id(
self: Handle<Self>,
app: &App,
) -> Option<(TypeId, HandleId)> { ... }
fn debug_fill_properties(
self: Handle<Self>,
app: &App,
properties: &mut DiagnosticPropertiesBuilder,
) { ... }
fn debug_describe_children(
self: Handle<Self>,
app: &App,
) -> Vec<Rc<dyn DiagnosticsNode>> { ... }
}Expand description
An instantiation of a Widget at a particular location in the tree.
Widgets describe how to configure a subtree but the same widget can be used to configure
multiple subtrees simultaneously because widgets are immutable. An Element represents
the use of a widget to configure a specific location in the tree. Over time, the widget
associated with a given element can change, for example, if the parent widget rebuilds
and creates a new widget for this location.
The overridable methods default to Dart’s base bodies; an override that must run the
base as well calls it through ElementBase (ElementBase::mount(self, ..)), where
Dart calls super.
Provided Associated Constants§
Sourceconst IS_RENDER_OBJECT_ELEMENT: bool = false
const IS_RENDER_OBJECT_ELEMENT: bool = false
Dart’s this is RenderObjectElement.
Sourceconst IS_PARENT_DATA_ELEMENT: bool = false
const IS_PARENT_DATA_ELEMENT: bool = false
Dart’s this is ParentDataElement.
Sourceconst IS_INHERITED_ELEMENT: bool = false
const IS_INHERITED_ELEMENT: bool = false
Dart’s this is InheritedElement.
Required Methods§
Sourcefn element_data(self: Handle<Self>, app: &App) -> &ElementData
fn element_data(self: Handle<Self>, app: &App) -> &ElementData
Dart’s base-class fields, held under the field element
(element_accessors!).
Sourcefn element_data_mut(self: Handle<Self>, app: &mut App) -> &mut ElementData
fn element_data_mut(self: Handle<Self>, app: &mut App) -> &mut ElementData
See element_data.
Provided Methods§
Sourcefn as_element(self: Handle<Self>) -> AnyElement
fn as_element(self: Handle<Self>) -> AnyElement
The type-erased handle to this element.
Sourcefn visit_children(
self: Handle<Self>,
app: &App,
visitor: &mut dyn FnMut(AnyElement),
)
fn visit_children( self: Handle<Self>, app: &App, visitor: &mut dyn FnMut(AnyElement), )
Calls the argument for each child. Must be overridden by subclasses that support having children.
There is no guaranteed order in which the children will be visited, though it should be consistent over time.
Sourcefn debug_visit_onstage_children(
self: Handle<Self>,
app: &App,
visitor: &mut dyn FnMut(AnyElement),
)
fn debug_visit_onstage_children( self: Handle<Self>, app: &App, visitor: &mut dyn FnMut(AnyElement), )
Calls the argument for each child considered onstage.
Classes like Offstage and Overlay override this method to hide their children.
Being onstage affects the element’s discoverability during testing when you use
flutter_test’s Finder. Offstage elements are ignored by finders by default.
Most widgets are not visible when offstage, but that is not always the case: an element that is offstage here may still paint.
Sourcefn render_object_attaching_child(
self: Handle<Self>,
app: &App,
) -> Option<AnyElement>
fn render_object_attaching_child( self: Handle<Self>, app: &App, ) -> Option<AnyElement>
Returns the child of this Element that will insert a RenderObject into an
ancestor of this Element to construct the render tree.
Returns None if this Element doesn’t have any children who need to attach a
RenderObject to an ancestor of this Element. A RenderObjectElement will
therefore return None because its children insert their RenderObjects into the
RenderObjectElement itself and not into an ancestor of the RenderObjectElement.
Sourcefn mount(
self: Handle<Self>,
app: &mut App,
parent: Option<AnyElement>,
new_slot: Option<Slot>,
)
fn mount( self: Handle<Self>, app: &mut App, parent: Option<AnyElement>, new_slot: Option<Slot>, )
Add this element to the tree in the given slot of the given parent.
The framework calls this function when a newly created element is added to the tree for the first time. Use this method to initialize state that depends on having a parent. State that is independent of the parent can more easily be initialized in the constructor.
Sourcefn update(self: Handle<Self>, app: &mut App, new_widget: WidgetRef)
fn update(self: Handle<Self>, app: &mut App, new_widget: WidgetRef)
Change the widget used to configure this element.
The framework calls this function when the parent wishes to use a different widget to
configure this element. The new widget is guaranteed to have the same runtimeType as
the old widget.
Sourcefn update_slot(self: Handle<Self>, app: &mut App, new_slot: Option<Slot>)
fn update_slot(self: Handle<Self>, app: &mut App, new_slot: Option<Slot>)
Called by AnyElement::update_slot_for_child when the slot for a child has changed.
Sourcefn attach_render_object(
self: Handle<Self>,
app: &mut App,
new_slot: Option<Slot>,
)
fn attach_render_object( self: Handle<Self>, app: &mut App, new_slot: Option<Slot>, )
Add AnyElement::render_object to the render tree at the location specified by
new_slot.
The default implementation of this function calls
attach_render_object recursively on each child. The
RenderObjectElement::attach_render_object override does the actual work of adding
AnyElement::render_object to the render tree.
Sourcefn detach_render_object(self: Handle<Self>, app: &mut App)
fn detach_render_object(self: Handle<Self>, app: &mut App)
Remove AnyElement::render_object from the render tree.
The default implementation of this function calls
detach_render_object recursively on each child. The
RenderObjectElement::detach_render_object override does the actual work of removing
AnyElement::render_object from the render tree.
Sourcefn forget_child(self: Handle<Self>, app: &mut App, child: AnyElement)
fn forget_child(self: Handle<Self>, app: &mut App, child: AnyElement)
Remove the given child from the element’s child list, in preparation for the child being reused elsewhere in the element tree.
Sourcefn activate(self: Handle<Self>, app: &mut App)
fn activate(self: Handle<Self>, app: &mut App)
Transition from the “inactive” to the “active” lifecycle state.
Sourcefn deactivate(self: Handle<Self>, app: &mut App)
fn deactivate(self: Handle<Self>, app: &mut App)
Transition from the “active” to the “inactive” lifecycle state.
Sourcefn debug_deactivated(self: Handle<Self>, app: &mut App)
fn debug_deactivated(self: Handle<Self>, app: &mut App)
Called, in debug mode, after children have been deactivated.
Sourcefn unmount(self: Handle<Self>, app: &mut App)
fn unmount(self: Handle<Self>, app: &mut App)
Transition from the “inactive” to the “defunct” lifecycle state.
Sourcefn perform_rebuild(self: Handle<Self>, app: &mut App)
fn perform_rebuild(self: Handle<Self>, app: &mut App)
Cause the widget to update itself.
Called by AnyElement::rebuild after the appropriate checks have been made.
Sourcefn did_change_dependencies(self: Handle<Self>, app: &mut App)
fn did_change_dependencies(self: Handle<Self>, app: &mut App)
Called when a dependency of this element changes.
Sourcefn update_inheritance(self: Handle<Self>, app: &mut App)
fn update_inheritance(self: Handle<Self>, app: &mut App)
Dart’s _updateInheritance: inherit the parent’s inherited-element map.
Sourcefn attach_notification_tree(self: Handle<Self>, app: &mut App)
fn attach_notification_tree(self: Handle<Self>, app: &mut App)
Called in mount and activate to register this
element in the notification tree.
This method is only exposed so that notifiable elements can be implemented (Dart’s
NotifiableElementMixin): an element that wishes to respond to notifications
overrides it to insert a node for itself, and on_notification
to handle them.
See also:
NotificationListener, a widget that allows listening to notifications.
Sourcefn build_scope(self: Handle<Self>, app: &App) -> Handle<BuildScope>
fn build_scope(self: Handle<Self>, app: &App) -> Handle<BuildScope>
The BuildScope whose dirty list this element is in.
The BuildOwner builds the dirty elements of one scope per build_scope call;
an element that wants its own (a LayoutBuilder, whose subtree is built during
layout) overrides this.
Sourcefn mark_needs_build(self: Handle<Self>, app: &mut App)
fn mark_needs_build(self: Handle<Self>, app: &mut App)
Marks the element as dirty and adds it to the global list of widgets to rebuild in the next frame.
Since it is inefficient to build an element twice in one frame, applications and widgets should be structured so as to only mark widgets dirty during event handlers before the frame begins, not during the build itself.
Sourcefn on_notification(
self: Handle<Self>,
app: &mut App,
notification: &dyn Notification,
) -> bool
fn on_notification( self: Handle<Self>, app: &mut App, notification: &dyn Notification, ) -> bool
Called when a notification of the appropriate type arrives at this location in the
tree (Dart’s NotifiableElementMixin.onNotification).
Return true to cancel the notification bubbling. Return false to allow the
notification to continue to be dispatched to further ancestors. Only elements that
override attach_notification_tree are asked.
Sourcefn debug_expects_render_object_for_slot(
self: Handle<Self>,
app: &App,
slot: Option<&Slot>,
) -> bool
fn debug_expects_render_object_for_slot( self: Handle<Self>, app: &App, slot: Option<&Slot>, ) -> bool
Whether the child in the provided slot (or one of its descendants) must insert a
RenderObject into its ancestor RenderObjectElement by calling
RenderObjectElement::insert_render_object_child on it.
Sourcefn render_object(self: Handle<Self>, app: &App) -> Option<AnyRenderObject>
fn render_object(self: Handle<Self>, app: &App) -> Option<AnyRenderObject>
The render object at (or below) this location in the tree.
Sourcefn debug_doing_build(self: Handle<Self>, app: &App) -> bool
fn debug_doing_build(self: Handle<Self>, app: &App) -> bool
Whether this element is in the middle of building.
Sourcefn insert_render_object_child(
self: Handle<Self>,
app: &mut App,
child: AnyRenderObject,
slot: Option<Slot>,
)
fn insert_render_object_child( self: Handle<Self>, app: &mut App, child: AnyRenderObject, slot: Option<Slot>, )
RenderObjectElement.insertRenderObjectChild.
Sourcefn move_render_object_child(
self: Handle<Self>,
app: &mut App,
child: AnyRenderObject,
old_slot: Option<Slot>,
new_slot: Option<Slot>,
)
fn move_render_object_child( self: Handle<Self>, app: &mut App, child: AnyRenderObject, old_slot: Option<Slot>, new_slot: Option<Slot>, )
RenderObjectElement.moveRenderObjectChild.
Sourcefn remove_render_object_child(
self: Handle<Self>,
app: &mut App,
child: AnyRenderObject,
slot: Option<Slot>,
)
fn remove_render_object_child( self: Handle<Self>, app: &mut App, child: AnyRenderObject, slot: Option<Slot>, )
RenderObjectElement.removeRenderObjectChild.
Sourcefn update_parent_data(
self: Handle<Self>,
app: &mut App,
parent_data_element: AnyElement,
)
fn update_parent_data( self: Handle<Self>, app: &mut App, parent_data_element: AnyElement, )
RenderObjectElement._updateParentData: apply a parent-data widget to this element’s
render object.
Sourcefn apply_parent_data(
self: Handle<Self>,
app: &mut App,
render_object: AnyRenderObject,
) -> bool
fn apply_parent_data( self: Handle<Self>, app: &mut App, render_object: AnyRenderObject, ) -> bool
ParentDataWidget.applyParentData through the element that holds the widget.
Sourcefn update_dependencies(
self: Handle<Self>,
app: &mut App,
dependent: AnyElement,
aspect: Option<Rc<dyn Any>>,
)
fn update_dependencies( self: Handle<Self>, app: &mut App, dependent: AnyElement, aspect: Option<Rc<dyn Any>>, )
InheritedElement.updateDependencies.
Sourcefn remove_dependent(self: Handle<Self>, app: &mut App, dependent: AnyElement)
fn remove_dependent(self: Handle<Self>, app: &mut App, dependent: AnyElement)
InheritedElement.removeDependent.
Sourcefn state_handle_id(self: Handle<Self>, app: &App) -> Option<(TypeId, HandleId)>
fn state_handle_id(self: Handle<Self>, app: &App) -> Option<(TypeId, HandleId)>
Dart’s this is StatefulElement && state is T: the state’s type and arena id.
Sourcefn debug_fill_properties(
self: Handle<Self>,
app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( self: Handle<Self>, app: &App, properties: &mut DiagnosticPropertiesBuilder, )
Dart’s debugFillProperties as an element class overrides it: the properties it adds
after Element’s, and RenderObjectElement’s for a render object element, which the
framework adds first since a trait default cannot call super.
Sourcefn debug_describe_children(
self: Handle<Self>,
app: &App,
) -> Vec<Rc<dyn DiagnosticsNode>>
fn debug_describe_children( self: Handle<Self>, app: &App, ) -> Vec<Rc<dyn DiagnosticsNode>>
Dart’s debugDescribeChildren: the children a dump shows under this element, by
default every child visit_children visits.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".