An Element that composes other Elements.
Rather than creating a RenderObject directly, a ComponentElement creates RenderObjects indirectly by creating other Elements.
Contrast with RenderObjectElement.
- Inheritance
- Object
- Element
- BuildableElement
- ComponentElement
Constructors
- ComponentElement(Widget widget)
-
Creates an element that uses the given widget as its configuration.
Properties
- 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.
read-only, inherited - dirty → bool
-
Returns true if the element has been marked as needing rebuilding.
read-only, inherited - hashCode → int
-
Get a hash code for this object.
read-only, inherited - owner → BuildOwner
-
The object that manages the lifecycle of this element.
read-only, inherited - renderObject → RenderObject
-
The render object at (or below) this location in the tree.
read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited - size → Size
-
read-only, inherited
- slot → dynamic
-
Information set by parent to define where this child fits in its parent's child list.
read-only, inherited - widget → Widget
-
The configuration for this element.
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
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.
-
mount(
Element parent, newSlot) → void -
Add this element to the tree in the given slot of the given parent.
-
performRebuild(
) → void -
Calls the
build
method of the StatelessWidget object (for stateless widgets) or the State object (for stateful widgets) and then updates the widget tree. -
visitChildren(
ElementVisitor visitor) → void -
Calls the argument for each child. Must be overridden by subclasses that support having children.
-
activate(
) → void -
Transition from the "inactive" to the "active" lifecycle state.
inherited -
ancestorInheritedElementForWidgetOfExactType(
Type targetType) → InheritedElement -
Obtains the element corresponding to the nearest widget of the given type, which must be the type of a concrete
InheritedWidget
subclass.inherited -
ancestorRenderObjectOfType(
TypeMatcher matcher) → RenderObject -
Returns the
RenderObject
object of the nearest ancestorRenderObjectWidget
widget that matches the givenTypeMatcher
.inherited -
ancestorStateOfType(
TypeMatcher matcher) → State -
Returns the
State
object of the nearest ancestorStatefulWidget
widget that matches the givenTypeMatcher
.inherited -
ancestorWidgetOfExactType(
Type targetType) → Widget -
Returns the nearest ancestor widget of the given type, which must be the type of a concrete
Widget
subclass.inherited -
attachRenderObject(
newSlot) → void -
Add renderObject to the render tree at the location specified by slot.
inherited -
deactivate(
) → void -
Transition from the "active" to the "inactive" lifecycle state.
inherited -
deactivateChild(
Element child) → void -
Move the given element to the list of inactive elements and detach its render object from the render tree.
inherited -
debugDeactivated(
) → void -
Called, in debug mode, after children have been deactivated (see deactivate).
inherited -
debugFillDescription(
List<String> description) → void -
Add additional information to the given description for use by
toString
.inherited -
debugGetCreatorChain(
int limit) → String -
Returns a description of what caused this element to be created.
inherited -
dependenciesChanged(
) → void -
Called when a dependency of this element changes.
inherited -
detachRenderObject(
) → void -
Remove renderObject from the render tree.
inherited -
findRenderObject(
) → RenderObject -
The current
RenderObject
for the widget. If the widget is aRenderObjectWidget
, this is the render object that the widget created for itself. Otherwise, it is the render object of the first descendantRenderObjectWidget
.inherited -
inflateWidget(
Widget newWidget, newSlot) → Element -
Create an element for the given widget and add it as a child of this element in the given slot.
inherited -
inheritFromWidgetOfExactType(
Type targetType) → InheritedWidget -
Obtains the nearest widget of the given type, which must be the type of a concrete
InheritedWidget
subclass, and registers this build context with that widget such that when that widget changes (or a new widget of that type is introduced, or the widget goes away), this build context is rebuilt so that it can obtain new values from that widget.inherited -
markNeedsBuild(
) → void -
Marks the element as dirty and adds it to the global list of widgets to rebuild in the next frame.
inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
rebuild(
) → void -
Called by the binding when BuildOwner.scheduleBuildFor has been called to mark this element dirty, and, in components, by mount when the element is first built and by update when the widget has changed.
inherited -
toString(
) → String -
Returns a string representation of this object.
inherited -
toStringDeep(
[String prefixLineOne = '', String prefixOtherLines = '' ]) → String -
A detailed, textual description of this element, includings its children.
inherited -
toStringShort(
) → String -
A short, textual description of this element.
inherited -
unmount(
) → void -
Transition from the "inactive" to the "defunct" lifecycle state.
inherited -
update(
Widget newWidget) → void -
Change the widget used to configure this element.
inherited -
updateChild(
Element child, Widget newWidget, newSlot) → Element -
Update the given child with the given new configuration.
inherited -
updateSlotForChild(
Element child, newSlot) → void -
Change the slot that the given child occupies in its parent.
inherited -
visitAncestorElements(
bool visitor(Element element)) → void -
Walks the ancestor chain, starting with the parent of this build context's widget, invoking the argument for each ancestor. The callback is given a reference to the ancestor widget's corresponding
Element
object. The walk stops when it reaches the root widget or when the callback returns false. The callback must not return null.inherited -
visitChildElements(
ElementVisitor visitor) → void -
Wrapper around visitChildren for BuildContext.
inherited -
visitChildrenForSemantics(
ElementVisitor visitor) → void -
Calls the argument for each child that is relevant for semantics. By default, defers to visitChildren. Classes like Offstage override this to hide their children.
inherited