Element class abstract

An instantiation of a Widget at a location in the element tree.

Implementers

Constructors

Element(Widget widget)
Creates an element backed by widget.

Properties

buildContext BuildContext
The BuildContext for this element.
no setter
children List<Element>
The child elements of this element.
final
hashCode int
The hash code for this object.
no setterinherited
mounted bool
Whether this element is currently in the tree.
getter/setter pair
owner BuildOwner
The owner that manages this element's build pipeline.
latefinal
parent Element?
The parent element, or null for the root.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
widget Widget
The widget this element currently represents.
getter/setter pair

Methods

debugDescribeWidget() String
Short debug description of this element's widget and key.
dependOnInheritedElementOfExactType<T extends InheritedWidget>({Object? aspect}) InheritedElement?
Registers this element as dependent on the nearest inherited widget of type T.
didLoseDependency(InheritedElement inherited) → void
Called when inherited removes this element from its dependents.
findAncestorRenderObjectOfExactType<T extends RenderObject>() → T?
Returns the nearest ancestor render object of type T.
findAncestorStateOfType<T extends State<StatefulWidget>>() → T?
Returns the nearest ancestor state of type T.
findAncestorWidgetOfExactType<T extends Widget>() → T?
Returns the nearest ancestor widget of type T.
findRenderObject() RenderObject?
The render object associated with this element, if any.
getElementForInheritedWidgetOfExactType<T extends InheritedWidget>() InheritedElement?
Returns the nearest inherited element of type T without registering a dependency.
insertRenderObjectChild(RenderObject child, Element childElement) → void
Bubble a render-object child insertion toward the nearest render parent.
mount(Element? parent, BuildOwner owner) → void
Inserts this element into the tree under parent and builds it.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyDependent(InheritedElement inherited, Object? aspect) → void
Called by inherited when it changes; schedules this element to rebuild.
performRebuild() → void
Rebuilds this element's subtree from its current widget configuration.
rebuild() → void
Rebuilds this element, refreshing its inherited-widget dependencies.
removeRenderObjectChild(RenderObject child, Element childElement) → void
Bubble a render-object child removal toward the nearest render parent.
toString() String
A string representation of this object.
inherited
unmount() → void
Removes this element and its descendants from the tree permanently.
update(Widget newWidget) → void
Updates this element to represent newWidget and rebuilds it.
visitAncestorElements(bool visitor(Element element)) → void
Walk up the element tree calling visitor for each ancestor until it returns false or the root is reached.
visitChildren(ElementVisitor visitor) → void
Calls visitor for each child element of this element.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

findDescendantRenderObject(Element element) RenderObject?
Recursively searches for a RenderObject in the element tree.
findRenderObjectElement(Element element) RenderObjectElement?
Recursively searches for a RenderObjectElement in the element tree.