paint method
- Canvas canvas,
- Rect rect, {
- double? gapStart,
- double gapExtent = 0.0,
- double gapPercentage = 0.0,
- TextDirection? textDirection,
override
Draw a horizontal line at the bottom of rect
.
The borderSide defines the line's color and weight. The textDirection
gap
and textDirection
parameters are ignored.
Implementation
@override
void paint(
Canvas canvas,
Rect rect, {
double? gapStart,
double gapExtent = 0.0,
double gapPercentage = 0.0,
TextDirection? textDirection,
}) {
if (borderSide.style == BorderStyle.none) {
return;
}
if (borderRadius.bottomLeft != Radius.zero || borderRadius.bottomRight != Radius.zero) {
// This prevents the border from leaking the color due to anti-aliasing rounding errors.
final BorderRadius updatedBorderRadius = BorderRadius.only(
bottomLeft: borderRadius.bottomLeft.clamp(maximum: Radius.circular(rect.height / 2)),
bottomRight: borderRadius.bottomRight.clamp(maximum: Radius.circular(rect.height / 2)),
);
BoxBorder.paintNonUniformBorder(canvas, rect,
textDirection: textDirection,
borderRadius: updatedBorderRadius,
bottom: borderSide.copyWith(strokeAlign: BorderSide.strokeAlignInside),
color: borderSide.color,
);
} else {
final Offset alignInsideOffset = Offset(0, borderSide.width / 2);
canvas.drawLine(rect.bottomLeft - alignInsideOffset, rect.bottomRight - alignInsideOffset, borderSide.toPaint());
}
}