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:

  1. Parent calls layout(constraints).
  2. Subclass performLayout(constraints) returns the chosen CellSize and lays out any children (calling layout on them in turn).
  3. Paint placement is the parent's responsibility — there is no setOffset on the child. Each parent remembers where it decided to put each child (e.g. RenderFlex keeps a child→offset map, RenderAlign a single child offset) and applies that during its own paint by calling child.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.)
  4. Parent calls paint(buffer, offset) during the paint pass. The offset passed 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

RenderObject()

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 Stack with an overflowing Positioned — answers true.
no setter
isRepaintBoundary → bool
Whether this render object owns its own paint cache (a CellBuffer it 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 child to 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 child from this render object.
layout(CellConstraints constraints) → CellSize
Lays out this render object against constraints and 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 buffer at offset: 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 buffer at offset.
presentsChild(RenderObject child) → bool
Whether child is presented this frame: painted and interactive. False for a child hidden by policy — an inactive IndexedStack child, 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 parentData is 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