ComponentElement class abstract
An element that builds one child widget.
- Inheritance
- Implementers
- Available extensions
Constructors
- ComponentElement(Widget widget)
-
An element of
widget, which builds its child when mounted.
Properties
- depth → int
-
The number of elements from the root to this one, the root's being 1.
no setterinherited
- dirty → bool
-
Whether this element is to be rebuilt in the next build scope.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- mounted → bool
-
Whether the element is still mounted: false once it was unmounted.
no setterinherited
- owner → BuildOwner?
-
The owner that builds the tree.
no setterinherited
- renderObject → RenderObject?
-
The render object of this element, or of the nearest element below it
that has one.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- slot → Object?
-
Where the parent placed this element among its children.
no setterinherited
- widget → Widget
-
The widget the element currently shows.
no setterinherited
Methods
-
activate(
) → void -
Called when this element, deactivated earlier in the frame, is back
in the tree, where a GlobalKey moved it or an element above it: it
finds the inherited widgets of its new place, and is rebuilt if it
depended on any, or if it was dirty.
inherited
-
attachRenderObject(
Object? newSlot) → void -
Puts the render objects of this subtree, which detachRenderObject
took out, back into the render tree at
newSlot.inherited -
build(
) → Widget - The child widget this element shows now.
-
deactivate(
) → void -
Called when this element leaves the tree: it no longer finds
inherited widgets, nor depends on any, unless activate puts it back.
inherited
-
deactivateChild(
Element child) → void -
Removes
childfrom the tree: its render objects leave the render tree now, and the owner unmounts it at the end of the frame unless a GlobalKey puts it back before.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Raises DiagnosticsFlag.error while it shows what the owner gave it in
place of a build that threw.
inherited
-
dependOnInheritedElement(
InheritedElement ancestor) → InheritedWidget -
Depends on
ancestor, the element of an inherited widget above this context, as dependOnInheritedWidgetOfExactType does, and returns its widget.inherited -
dependOnInheritedWidgetOfExactType<
T extends InheritedWidget> () → T? -
The nearest InheritedWidget of exactly the type
Tabove this context (or the context's own widget), found in constant time; null if there is none.inherited -
describe(
) → DiagnosticsNode -
This element and those below it as a tree of descriptions, built when
called: its widget's type and key; the properties
debugFillProperties adds; the size of its render object, or of the
nearest below it, once laid out; whether it is to be rebuilt
(DiagnosticsFlag.needsBuild); and the descriptions of its children.
debugDumpAppprints it.inherited -
detachRenderObject(
) → void -
Takes the render objects of this subtree out of the render tree.
inherited
-
didChangeDependencies(
) → void -
Called when something this element depends on changed: it rebuilds.
inherited
-
findAncestorStateOfType<
T extends State< (StatefulWidget> >) → T? -
The state of the nearest stateful ancestor whose state is a
T.inherited -
findAncestorWidgetOfExactType<
T extends Widget> () → T? -
The widget of the nearest ancestor whose widget is exactly a
T.inherited -
findRenderObject(
) → RenderObject? -
The render object of the element, or of the nearest element below it
that has one.
inherited
-
forgetChild(
Element child) → void -
Lets go of
child, which a GlobalKey is moving under another element: this element no longer visits it, and leaves it out when it next updates its children.inherited -
getElementForInheritedWidgetOfExactType<
T extends InheritedWidget> () → InheritedElement? -
The element of the widget dependOnInheritedWidgetOfExactType finds,
without depending on it.
inherited
-
getInheritedWidgetOfExactType<
T extends InheritedWidget> () → T? -
The widget dependOnInheritedWidgetOfExactType finds, without
depending on it.
inherited
-
inflateWidget(
Widget newWidget, Object? newSlot) → Element -
Creates the element of
newWidgetand mounts it as a child of this one atnewSlot. For a widget with a GlobalKey, the element of the key moves here instead if the widget can update it, wherever it is in the tree or among the elements removed in the frame: with its subtree, state and render objects, the old parent letting go of it. When that throws, what was mounted or moved here leaves the tree again.inherited -
markNeedsBuild(
) → void -
Rebuilds this element in its owner's next build scope.
inherited
-
mount(
Element? parent, Object? newSlot) → void -
Places this element in the tree under
parent(null for a root, whose owner is assigned before) atnewSlot.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
performRebuild(
) → void -
Builds the child widget and makes the child show it. A build that
throws is reported to the owner, and the child shows what the owner
returns instead; so is what is thrown below as the child is made to
show it, other than by the builds there (a createRenderObject,
updateRenderObject, initState or didUpdateWidget), which goes on up
when the owner has no BuildOwner.onBuildError.
override
-
read<
T> () → T -
Available on BuildContext, provided by the ReadContext extension
TheTof the nearest provider of one above this context, without depending on it: for callbacks, ascontext.read<Counter>().increment()on a key, and for State.initState. A ProviderNotFoundException if there is none, unlessTis nullable: then null. -
reassemble(
) → void -
Has this element and those below it rebuild, as a hot reload of the
app's code needs (
AppBinding.reassemble): a State is told with State.reassemble.inherited -
rebuild(
{bool force = false}) → void -
Rebuilds this element if it is dirty, or
forced, and in the tree.inherited -
select<
T, R> (R selector(T value)) → R -
Available on BuildContext, provided by the SelectContext extension
Whatselectorpicks from theTof the nearest provider of one above this context, which is rebuilt only when a change of the value makesselectorpick something else: not==, lists, sets, maps and other iterables compared element by element. A build may select any number of parts, of one value or of several; each build selects anew. A ProviderNotFoundException if there is none, unlessTis nullable. -
toString(
) → String -
The type of its widget, the key after a dash: what messages name it
by.
inherited
-
unmount(
) → void -
Called when this element is unmounted for good, after deactivate.
inherited
-
update(
covariant Widget newWidget) → void -
Shows
newWidget, which Widget.canUpdate matched with widget.inherited -
updateChild(
Element? child, Widget? newWidget, Object? newSlot) → Element? -
Makes
childshownewWidgetatnewSlotand returns the element that does:childitself when the widget is the same or matches it, else a new element in its place. A nullnewWidgetremoveschild.inherited -
updateChildren(
List< Element> oldChildren, List<Widget> newWidgets, {Set<Element> ? forgottenChildren}) → List<Element> -
Makes
oldChildrenshownewWidgetsand returns the elements that do, in order; each child's slot is an IndexedSlot. As in Flutter, the matching heads of both lists are updated in place, then the middles, where an old child with a key goes on to the new widget with that key and the other old children are removed, then the matching tails. So a child inserted or removed leaves its siblings their elements, and children with keys keep theirs, render objects moved, when reordered. TheforgottenChildrenamongoldChildren, which forgetChild let go, are no longer there: they are neither updated nor removed.inherited -
updateSlot(
Object? newSlot) → void -
Moves this element to
newSlotamong its parent's children.inherited -
updateSlotForChild(
Element child, Object? newSlot) → void -
Moves
childtonewSlot, along with the elements below it down to the one whose render object stands for it.inherited -
visitAncestorElements(
ConditionalElementVisitor visitor) → void -
Calls
visitorfor each ancestor, nearest first, until it returns false.inherited -
visitChildren(
ElementVisitor visitor) → void -
Calls
visitorfor each child.inherited -
watch<
T> () → T -
Available on BuildContext, provided by the WatchContext extension
TheTof the nearest provider of one above this context, which is rebuilt each time it changes, as long as its builds watch it. A ProviderNotFoundException if there is none, unlessTis nullable: then null.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited