Element class abstract

An instantiation of a Component at a particular location in the tree.

Components describe how to configure a subtree but the same component can be used to configure multiple subtrees simultaneously because components are immutable. An Element represents the use of a component to configure a specific location in the tree. Over time, the component associated with a given element can change, for example, if the parent component rebuilds and creates a new component for this location..

Implemented types
Available extensions

Constructors

Element(Component component)
Creates an element that uses the given component as its configuration.

Properties

binding AppBinding
The root component binding that manages the component tree.
no setteroverride
component Component
The configuration for this element.
no setteroverride
debugDoingBuild bool
Whether the component is currently updating the component or render tree.
no setterinherited
depth int
An integer that is guaranteed to be greater than the parent's, if any. The element at the root of the tree must have a depth greater than 0.
no setter
dirty bool
no setter
hashCode int
The hash code for this object.
no setteroverride
owner BuildOwner
The root build owner that manages the build cycle.
no setter
parent Element?
no setter
parentRenderObjectElement RenderObjectElement?
no setter
project Project

Available on BuildContext, provided by the ProjectContext extension

Returns the Project from the nearest ancestor ProjectProvider.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
screen Screen

Available on BuildContext, provided by the ScreenContext extension

Access responsive rendering helpers.
no setter
slot ElementSlot
Information set by parent to define where this child fits in its parent's child list.
no setter
theme Theme

Available on BuildContext, provided by the ThemeContext extension

Returns the Theme from the nearest ancestor ThemeProvider.
no setter
url String

Available on BuildContext, provided by the AppContext extension

The currently active url.
no setter

Methods

activate() → void
Transition from the "inactive" to the "active" lifecycle state.
attachNotificationTree() → void
Called in Element.mount and Element.activate to register this element in the notification tree.
attachRenderObject() → void
deactivate() → void
Transition from the "active" to the "inactive" lifecycle state.
deactivateChild(Element child) → void
Move the given element to the list of inactive elements and detach its render object from the render tree.
dependOnInheritedComponentOfExactType<T extends InheritedComponent>({Object? aspect}) → T?
Obtains the nearest component of the given type T, which must be the type of a concrete InheritedComponent subclass, and registers this build context with that component such that when that component changes (or a new component of that type is introduced, or the component goes away), this build context is rebuilt so that it can obtain new values from that component.
override
dependOnInheritedElement(InheritedElement ancestor, {Object? aspect}) InheritedComponent
Registers this build context with ancestor such that when ancestor's component changes this build context is rebuilt.
override
detachRenderObject() → void
didChangeDependencies() → void
Called when a dependency of this element changes.
didMount() → void
didRebuild() → void
didUpdate(covariant Component oldComponent) → void
dispatchNotification(Notification notification) → void
Start bubbling this notification at the given build context.
override
findAncestorStateOfType<T extends State<StatefulComponent>>() → T?
Returns the State object of the nearest ancestor StatefulComponent component that is an instance of the given type T.
override
forgetChild(Element child) → void
Remove the given child from the element's child list, in preparation for the child being reused elsewhere in the element tree.
getElementForInheritedComponentOfExactType<T extends InheritedComponent>() InheritedElement?
Obtains the element corresponding to the nearest component of the given type T, which must be the type of a concrete InheritedComponent subclass.
override
inflateComponent(Component newComponent, ElementSlot newSlot) Element
Create an element for the given component and add it as a child of this element.
markNeedsBuild() → void
Marks the element as dirty and schedules a rebuild.
mount(Element? parent, ElementSlot newSlot) → void
Add this element to the tree as a child of the given parent.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
performRebuild() → void
Cause the component to update itself.
rebuild() → void
Cause the component to update itself.
shouldRebuild(covariant Component newComponent) bool
Implement this method to determine whether a rebuild can be skipped.
toString() String
A string representation of this object.
inherited
unmount() → void
Transition from the "inactive" to the "defunct" lifecycle state.
update(covariant Component newComponent) → void
Change the component used to configure this element.
updateChild(Element? child, Component? newComponent, ElementSlot newSlot) Element?
Update the given child with the given new configuration.
updateChildren(List<Element> oldChildren, List<Component> newComponents, {Set<Element>? forgottenChildren}) List<Element>
Updates the children of this element to use new components.
updateSlot(ElementSlot newSlot) → void
Called by updateSlotForChild when the framework needs to change the slot that this Element occupies in its ancestor.
updateSlotForChild(Element child, ElementSlot newSlot) → void
Change the slot that the given child occupies in its parent.
visitAncestorElements(bool visitor(Element element)) → void
Walks the ancestor chain, starting with the parent of this build context's component, invoking the argument for each ancestor. The callback is given a reference to the ancestor component's corresponding Element object. The walk stops when it reaches the root component or when the callback returns false. The callback must not return null.
override
visitChildElements(ElementVisitor visitor) → void
Wrapper around visitChildren for BuildContext.
override
visitChildren(ElementVisitor visitor) → void
Calls the argument for each child.

Operators

operator ==(Object other) bool
Compare two components for equality.
override