RenderObjectWidget class abstract
A widget with a render object of the core: its element creates the render object, updates it with each new widget and places it in the render tree under the render object of the nearest ancestor that has one.
A widget of an app's own that lays out and paints writes its render object, and creates it here; this one paints three dots:
final class Dots extends LeafRenderObjectWidget {
const Dots({super.key});
@override
RenderObject createRenderObject(BuildContext context) => _RenderDots();
}
final class _RenderDots extends RenderObject {
@override
void performLayout(BoxConstraints c) {
width = c.constrainWidth(3);
height = c.constrainHeight(1);
}
@override
void paint(PaintContext ctx) {
final canvas = ctx.canvas;
canvas.text(0, 0, '...', canvas.styles.pen(const Pen()));
}
}
A widget with fields updates the render object from them in updateRenderObject too, as RenderObject's own example shows.
- Inheritance
- Implementers
Constructors
- RenderObjectWidget({Key? key})
-
For subclasses.
const
Properties
Methods
-
createElement(
) → RenderObjectElement -
Inflates this widget into a new element for the tree.
override
-
createRenderObject(
BuildContext context) → RenderObject - Creates the render object, configured from this widget.
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Adds what describes this widget in its element's description
(Element.describe) to
properties, those not worth showing (a default) left out; an override calls this first. A render object widget adds only what its render object does not show. Only Element.describe calls it: a frame never does.inherited -
didUnmountRenderObject(
covariant RenderObject renderObject) → void -
Called when the element of
renderObjectwas unmounted: release what the render object holds. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateRenderObject(
BuildContext context, covariant RenderObject renderObject) → void -
Configures
renderObjectfrom this widget: called when it replaced the widget that created or last configured the render object, and when the element is rebuilt.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited