paint method

  1. @override
void paint(
  1. Context context
)
override

Draw itself and its children, according to the calculated box.offset

Implementation

@override
void paint(Context context) {
  super.paint(context);
  paintChild(context);
  final resolvedMargin = margin.resolve(Directionality.of(context));
  context.canvas.saveContext();
  context.canvas.setGraphicState(PdfGraphicState(opacity: opacity));
  context.canvas.setStrokeColor(horizontalColor);
  final l = scale;
  final m = l / 2;
  final s = m / 2;

  final allHorizontalDivisions =
      (horizontalDivisions * horizontalSubdivisions).toDouble();
  var n = horizontalOffset;
  for (var x = box!.left + resolvedMargin.left;
      x <= box!.right - resolvedMargin.right;
      x += horizontalInterval / allHorizontalDivisions) {
    context.canvas
      ..setLineWidth((n % (horizontalSubdivisions * horizontalDivisions) == 0)
          ? l
          : (n % horizontalSubdivisions == 0)
              ? m
              : s)
      ..drawLine(x, box!.top, x, box!.bottom)
      ..strokePath();
    n++;
  }

  context.canvas.setStrokeColor(verticalColor);
  final allVerticalDivisions =
      (verticalDivisions * verticalSubdivisions).toDouble();
  n = verticalOffset;
  for (var y = box!.top - resolvedMargin.top;
      y >= box!.bottom + resolvedMargin.bottom;
      y -= verticalInterval / allVerticalDivisions) {
    context.canvas
      ..setLineWidth((n % (verticalSubdivisions * verticalDivisions) == 0)
          ? l
          : (n % verticalSubdivisions == 0)
              ? m
              : s)
      ..drawLine(box!.left, y, box!.right, y)
      ..strokePath();
    n++;
  }

  if (border.left.style.paint) {
    border.left.style.setStyle(context);
    context.canvas
      ..setStrokeColor(border.left.color)
      ..setLineWidth(border.left.width)
      ..drawLine(box!.left + resolvedMargin.left, box!.top,
          box!.left + resolvedMargin.left, box!.bottom)
      ..strokePath();
    border.left.style.unsetStyle(context);
  }
  if (border.right.style.paint) {
    border.right.style.setStyle(context);
    context.canvas
      ..setStrokeColor(border.right.color)
      ..setLineWidth(border.right.width)
      ..drawLine(box!.right - resolvedMargin.right, box!.top,
          box!.right - resolvedMargin.right, box!.bottom)
      ..strokePath();
    border.right.style.unsetStyle(context);
  }
  if (border.top.style.paint) {
    border.top.style.setStyle(context);
    context.canvas
      ..setStrokeColor(border.top.color)
      ..setLineWidth(border.top.width)
      ..drawLine(box!.left, box!.top - resolvedMargin.top, box!.right,
          box!.top - resolvedMargin.top)
      ..strokePath();
    border.top.style.unsetStyle(context);
  }
  if (border.bottom.style.paint) {
    border.bottom.style.setStyle(context);
    context.canvas
      ..setStrokeColor(border.bottom.color)
      ..setLineWidth(border.bottom.width)
      ..drawLine(box!.left, box!.bottom + resolvedMargin.bottom, box!.right,
          box!.bottom + resolvedMargin.bottom)
      ..strokePath();
    border.bottom.style.unsetStyle(context);
  }

  context.canvas.restoreContext();
}