paintDottedBorder method

void paintDottedBorder(
  1. Canvas canvas,
  2. Rect rect, {
  3. BorderSide top = BorderSide.none,
  4. BorderSide right = BorderSide.none,
  5. BorderSide bottom = BorderSide.none,
  6. 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;

      canvas.drawPath(_buildDashPath(path, dottedLength, dottedSpace),
          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;

      canvas.drawPath(_buildDashPath(path, dottedLength, dottedSpace),
          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;
      canvas.drawPath(_buildDashPath(path, dottedLength, dottedSpace),
          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;
      canvas.drawPath(_buildDashPath(path, dottedLength, dottedSpace),
          paint..strokeWidth = left.width);
      break;
    case BorderStyle.none:
      break;
  }
}