ADVANCED FLUTTER

Render Objects

Learn the foundation of Flutter's rendering layer. Master the primitives that paint every pixel on screen.

my_render_box.dart
class MyRenderBox extends RenderBox {
  // Override to define your layout logic
  @override
  void performLayout() {
    size = constraints.biggest;
  }

  // Paint to the canvas at the given offset
  @override
  void paint(PaintingContext ctx, Offset offset) {
    ctx.canvas.drawRect(
      offset & size,
      Paint()..color = color,
    );
  }
}
20guides
16api docs
5examples
1render kit

Render Object Guides

With AI, you can outsource your knowledge, but not your understanding. Learn the fundamental behaviors of render objects with our guides.

View all guides →

Surgical Help

Get help implementing specific render object methods with our API docs.

performLayout() docs →

Calculates the size of this render object and positions all its children. Must set this.size before returning.

void — called by the framework during the layout phase
paint(PaintingContext context, Offset offset) docs →

Draws the visual representation of this render object onto the composited layer. Called after layout completes.

void — uses context.canvas for direct drawing operations
hitTest(BoxHitTestResult result, {required Offset position}) docs →

Determines whether a pointer event at position falls within this render object. Returns true to claim the event.

bool — true if the hit test is absorbed by this render object
View full API reference →