- override
Paint this render object into the given context at the given offset.
Subclasses should override this method to provide a visual appearance for themselves. The render object's local coordinate system is axis-aligned with the coordinate system of the context's canvas and the render object's local origin (i.e, x=0 and y=0) is placed at the given offset in the context's canvas.
Do not call this function directly. If you wish to paint yourself, call
markNeedsPaint
instead to schedule a call to this function. If you wish
to paint one of your children, call one of the paint child functions on
the given context, such as paintChild
or paintChildWithClipRect
.
When painting one of your children (via a paint child function on the given context), the current canvas held by the context might change because draw operations before and after painting children might need to be recorded on separate compositing layers.
Source
@override void paint(PaintingContext context, Offset offset) { if (_overflow <= 0.0) { defaultPaint(context, offset); return; } // We have overflow. Clip it. context.pushClipRect(needsCompositing, offset, Point.origin & size, defaultPaint); assert(() { // In debug mode, if you have overflow, we highlight where the // overflow would be by painting that area red. Since that is // likely to be clipped by an ancestor, we also draw a thick red // line at the edge that's overflowing. // If you do want clipping, use a RenderClip (Clip in the // Widgets library). Paint markerPaint = new Paint()..color = const Color(0xE0FF0000); Paint highlightPaint = new Paint()..color = const Color(0x7FFF0000); const double kMarkerSize = 0.1; Rect markerRect, overflowRect; switch(direction) { case Axis.horizontal: markerRect = offset + new Offset(size.width * (1.0 - kMarkerSize), 0.0) & new Size(size.width * kMarkerSize, size.height); overflowRect = offset + new Offset(size.width, 0.0) & new Size(_overflow, size.height); break; case Axis.vertical: markerRect = offset + new Offset(0.0, size.height * (1.0 - kMarkerSize)) & new Size(size.width, size.height * kMarkerSize); overflowRect = offset + new Offset(0.0, size.height) & new Size(size.width, _overflow); break; } context.canvas.drawRect(markerRect, markerPaint); context.canvas.drawRect(overflowRect, highlightPaint); return true; }); }