RenderObject class abstract
Base for everything that participates in layout and paint.
The contract is the Flutter constraints-down / sizes-up protocol, translated to integer cell coordinates:
- Parent calls
layout(constraints). - Subclass
performLayout(constraints)returns the chosen CellSize and lays out any children (callinglayouton them in turn). - Paint placement is the parent's responsibility — there is no
setOffseton the child. Each parent remembers where it decided to put each child (e.g.RenderFlexkeeps a child→offset map,RenderAligna single child offset) and applies that during its ownpaintby callingchild.paint(buffer, offset + childOffset). So offsets live in the parent, not as state on the child. (A ParentData slot exists for parents that prefer to stash layout bookkeeping on the child, but most parents use their own fields.) - Parent calls
paint(buffer, offset)during the paint pass. Theoffsetpassed in is the absolute position in the buffer.
Subclasses must call super.layout (or invoke the protocol on each
child themselves); the framework relies on _size being current after
every layout pass.
- Implemented types
- Implementers
Constructors
Properties
- constraints → CellConstraints
-
The constraints from the most recent layout pass.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasLayout → bool
-
Whether this render object has been laid out at least once.
no setter
- hitTestsBeyondBounds → bool
-
Whether a point outside this render object's box can hit something in
its subtree. False by default: hit-testing prunes a subtree by its box,
as Flutter does, so a pointer event walks one chain of the tree rather
than every region. A container that places children outside its box
and wants them to stay interactive there — a
Stackwith an overflowingPositioned— answers true.no setter - isRepaintBoundary → bool
-
Whether this render object owns its own paint cache (a
CellBufferit can blit instead of re-walking its subtree's paint). Override to true in subclasses that implement the cache discipline.no setter - needsLayout → bool
-
Whether this render object must run performLayout the next time it is
reached with the same constraints. Constraints changes always force a new
layout even when this flag is false.
no setter
- needsPaint ↔ bool
-
Whether the enclosing boundary's cache has been invalidated. Set true
by markNeedsLayout and markNeedsPaintOnly; subclasses that implement
a paint cache clear it once they have re-painted into their cache.
getter/setter pair
- paintOverflow → CellRect?
-
Conservative local bounds when this subtree can paint outside size.
Null means its layout box contains all paint. Containers derive this
from presented children, their offsets and clips. Results are cached;
layout or paint invalidation invalidates the enclosing bounds as well.
Custom painters that draw beyond their box override computePaintOverflow.
no setter
- parent → RenderObject?
-
no setter
- parentData ↔ ParentData?
-
getter/setter pair
- rootFrameDamage → RenderDamageTracker?
-
The frame damage tracker attached at this tree's root — the per-owner
object a render object publishes frame-scoped facts into — or null while
detached or before the first frame.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → CellSize
-
The size computed by the most recent layout pass.
no setter
Methods
-
adoptChild(
RenderObject child) → void -
Attaches
childto this render object as its parent. Subclasses that hold children call this whenever they accept one; it also gives the parent a chance to ensure RenderObject.parentData is the right type via setupParentData. -
attachFrameDamageTracker(
RenderDamageTracker tracker) → bool - Attaches the per-runtime damage tracker at this (root) render object.
-
childClipOf(
RenderObject child) → CellRect? -
The clip this render object imposes on
child, in its own coordinates, or null when it does not clip. Usually the same rectangle for every child (a viewport); a container with several scrolling regions — a table with a pinned header — answers per child. -
childOffsetOf(
RenderObject child) → CellOffset -
Where this render object paints
child, relative to its own origin. -
computeMaxIntrinsicHeight(
int? width) → int -
The tallest this render object would want to be at the given
width. -
computeMaxIntrinsicWidth(
int? height) → int -
The widest this render object would want to be at the given
height. Most relevant override: text returns its unwrapped width. -
computeMinIntrinsicHeight(
int? width) → int -
The shortest this render object can be at the given
width. -
computeMinIntrinsicWidth(
int? height) → int - The narrowest width below which content would clip. Text-like leaves can return a longest-token width if they word-wrap.
-
computePaintOverflow(
) → CellRect? -
dropChild(
RenderObject child) → void -
Detaches
childfrom this render object. -
layout(
CellConstraints constraints) → CellSize -
Lays out this render object against
constraintsand returns the chosen size. Subclasses implement performLayout rather than overriding this; the framework needs the bookkeeping around it. -
markAncestorRepaintBoundariesDirty(
) → void - Marks every repaint boundary STRICTLY ABOVE this node as needing paint.
-
markNeedsLayout(
) → void - Marks this render object and its ancestors as needing layout, and marks the nearest enclosing repaint boundary as dirty. Use this for changes that can affect size, child constraints, child offsets, or layout-derived paint state.
-
markNeedsPaintOnly(
) → void - Marks this render object's painted output as stale without touching layout.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
paint(
CellBuffer buffer, CellOffset offset) → void -
Paints this render object into
bufferatoffset: its origin in the buffer's coordinates. The buffer's bounds are the clip. -
performLayout(
CellConstraints constraints) → CellSize -
Override to compute the chosen size and lay out children. Must
return a size that satisfies
constraints. -
performPaint(
CellBuffer buffer, CellOffset offset) → void -
Paints this render object's cells into
bufferatoffset. -
presentsChild(
RenderObject child) → bool -
Whether
childis presented this frame: painted and interactive. False for a child hidden by policy — an inactiveIndexedStackchild, a route under an opaque route, an overlay entry under an opaque one, a list row outside the mounted window, a contained-error subtree. -
screenGeometry(
) → RenderGeometry? -
This render object's screen geometry, derived from layout state: where
it is, and how much of it is visible.
override
-
setupParentData(
RenderObject child) → void -
Override to install a subclass of ParentData on the child. The
default is a no-op; multi-child render objects override this so a
child's
parentDatais always the type that parent expects. -
toString(
) → String -
A string representation of this object.
inherited
-
visitRenderChildren(
void visitor(RenderObject child)) → void - Visits this render object's children in paint order. The default reads the single-child / multi-child interfaces; a container whose RenderObjectWithChildren.children accessor copies its list overrides this to iterate in place, since hit-testing and geometry tooling walk the tree on every event.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited