paintDottedBorder method
void
paintDottedBorder(
- Canvas canvas,
- Rect rect, {
- BorderSide top = BorderSide.none,
- BorderSide right = BorderSide.none,
- BorderSide bottom = BorderSide.none,
- BorderSide left = BorderSide.none,
Implementation
void paintDottedBorder(
Canvas canvas,
Rect rect, {
BorderSide top = BorderSide.none,
BorderSide right = BorderSide.none,
BorderSide bottom = BorderSide.none,
BorderSide left = BorderSide.none,
}) {
// We draw the borders as filled shapes, unless the borders are hairline
// borders, in which case we use PaintingStyle.stroke, with the stroke width
// specified here.
final Paint paint = Paint()..strokeWidth = 0.0;
final Path path = Path();
switch (top.style) {
case BorderStyle.solid:
paint.color = top.color;
path.reset();
path.moveTo(rect.left, rect.top + top.width / 2);
path.lineTo(rect.right, rect.top + top.width / 2);
paint.style = PaintingStyle.stroke;
if (top is RBorderSide) {
top.paint(canvas, path, paint..strokeWidth = top.width);
} else {
canvas.drawPath(path, paint..strokeWidth = top.width);
}
break;
case BorderStyle.none:
break;
}
switch (right.style) {
case BorderStyle.solid:
paint.color = right.color;
path.reset();
path.moveTo(rect.right, rect.top);
path.lineTo(rect.right, rect.bottom);
paint.style = PaintingStyle.stroke;
if (right is RBorderSide) {
right.paint(canvas, path, paint..strokeWidth = right.width);
} else {
canvas.drawPath(path, paint..strokeWidth = right.width);
}
break;
case BorderStyle.none:
break;
}
switch (bottom.style) {
case BorderStyle.solid:
paint.color = bottom.color;
path.reset();
path.moveTo(rect.right, rect.bottom);
path.lineTo(rect.left, rect.bottom);
paint.style = PaintingStyle.stroke;
if (bottom is RBorderSide) {
bottom.paint(canvas, path, paint..strokeWidth = bottom.width);
} else {
canvas.drawPath(path, paint..strokeWidth = bottom.width);
}
break;
case BorderStyle.none:
break;
}
switch (left.style) {
case BorderStyle.solid:
paint.color = left.color;
path.reset();
path.moveTo(rect.left + left.width / 2, rect.bottom);
path.lineTo(rect.left + left.width / 2, rect.top);
paint.style = PaintingStyle.stroke;
if (left is RBorderSide) {
left.paint(canvas, path, paint..strokeWidth = left.width);
} else {
canvas.drawPath(path, paint..strokeWidth = left.width);
}
break;
case BorderStyle.none:
break;
}
}