paint method
Paints the border within the given Rect on the given Canvas.
The textDirection
argument must be provided and non-null if the border
has a text direction dependency (for example if it is expressed in terms
of "start" and "end" instead of "left" and "right"). It may be null if
the border will not need the text direction to paint itself.
Implementation
@override
void paint(
Canvas canvas,
Rect rect, {
TextDirection? textDirection,
}) {
final actualSide = effectiveSide;
final sideWidth = actualSide.effectiveWidth;
if (sideWidth == 0) return;
final Paint paint = actualSide.toPaint(rect);
final RRect borderRect = corners.resolve(textDirection).toRRect(rect);
final RRect outer = borderRect.inflate(actualSide.strokeOutset);
if (actualSide.effectiveStyle.isSolid) {
final RRect inner = borderRect.deflate(actualSide.strokeInset);
canvas.drawDRRect(outer, inner, paint);
} else {
final borderPath = getNonSolidPath(
Path()..addRRect(outer),
textDirection: textDirection,
);
canvas.drawPath(
borderPath,
paint
..strokeWidth = sideWidth
..style = PaintingStyle.stroke,
);
}
}