abstractclassElementextendsDiagnosticableTreeimplementsBuildContext{ /// Creates an element that uses the given widget as its configuration. /// /// Typically called by an override of [Widget.createElement]. Element(Widget widget) : assert(widget != null), _widget = widget;
/// 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. /// /// This function is called only during the "active" lifecycle state. @mustCallSuper void update(covariant Widget newWidget) { /// ... }
/// Creates an instance of the [RenderObject] class that this /// [RenderObjectWidget] represents, using the configuration described by this /// [RenderObjectWidget]. /// /// This method should not do anything with the children of the render object. /// That should instead be handled by the method that overrides /// [RenderObjectElement.mount] in the object rendered by this object's /// [createElement] method. See, for example, /// [SingleChildRenderObjectElement.mount]. @protected RenderObject createRenderObject(BuildContext context); }
/// The render object at (or below) this location in the tree. /// /// If this object is a [RenderObjectElement], the render object is the one at /// this location in the tree. Otherwise, this getter will walk down the tree /// until it finds a [RenderObjectElement]. RenderObject get renderObject { RenderObject result; void visit(Element element) { assert(result == null); // this verifies that there's only one child if (element is RenderObjectElement) result = element.renderObject; else element.visitChildren(visit); } visit(this); return result; }