paintEdgesBarPath method

void paintEdgesBarPath(
  1. Canvas canvas,
  2. Size size, {
  3. required Paint edges,
  4. required Offset centerLeft,
  5. required Offset centerRight,
  6. required double halfLineWidth,
})

Implementation

void paintEdgesBarPath(
  Canvas canvas,
  Size size, {
  required Paint edges,
  required Offset centerLeft,
  required Offset centerRight,
  required double halfLineWidth,
}) {
  if (style.borderRadius == 0) {
    canvas.drawPath(
      Path()
        // LEFT EDGE
        ..addRect(
          Rect.fromCenter(
            center: centerLeft,
            width: style.edgesSize,
            height: size.height + style.lineWidth * 2,
          ),
        )
        // RIGTH EDGE
        ..addRect(
          Rect.fromCenter(
            center: centerRight,
            width: style.edgesSize,
            height: size.height + style.lineWidth * 2,
          ),
        ),
      edges,
    );
  }

  final borderRadius = Radius.circular(style.borderRadius);

  /// Left and right edges, with a reversed border radius on the inside of the rect
  canvas.drawPath(
    // LEFT EDGE
    Path()
      ..fillType = PathFillType.evenOdd
      ..addRRect(
        RRect.fromRectAndCorners(
          Rect.fromLTWH(
            centerLeft.dx - halfLineWidth,
            -style.lineWidth,
            style.edgeWidth + style.borderRadius,
            size.height + style.lineWidth * 2,
          ),
          topLeft: borderRadius,
          bottomLeft: borderRadius,
        ),
      )
      ..addRRect(
        RRect.fromRectAndCorners(
          Rect.fromLTWH(
            centerLeft.dx + halfLineWidth,
            0.0,
            style.borderRadius,
            size.height,
          ),
          topLeft: borderRadius,
          bottomLeft: borderRadius,
        ),
      ),
    edges,
  );

  canvas.drawPath(
    // RIGHT EDGE
    Path()
      ..fillType = PathFillType.evenOdd
      ..addRRect(
        RRect.fromRectAndCorners(
          Rect.fromLTWH(
            centerRight.dx - halfLineWidth - style.borderRadius,
            -style.lineWidth,
            style.edgeWidth + style.borderRadius,
            size.height + style.lineWidth * 2,
          ),
          topRight: borderRadius,
          bottomRight: borderRadius,
        ),
      )
      ..addRRect(
        RRect.fromRectAndCorners(
          Rect.fromLTWH(
            centerRight.dx - halfLineWidth - style.borderRadius,
            0.0,
            style.borderRadius,
            size.height,
          ),
          topRight: borderRadius,
          bottomRight: borderRadius,
        ),
      ),
    edges,
  );
}