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);

  final bf = PdfButtonField(
    rect: context.localToGlobal(box!),
    fieldName: name,
    value: value ? '/Yes' : null,
    defaultValue: value ? '/Yes' : null,
    flags: <PdfAnnotFlags>{PdfAnnotFlags.print},
  );

  final mat = getAppearanceMatrix(context);

  drawAppearance(
    context,
    bf,
    mat,
    name: '/Yes',
    selected: value,
    CustomPaint(
      size: bf.rect.size,
      painter: (canvas, size) {
        canvas.drawRRect(
            0, 0, bf.rect.width, bf.rect.height, radius.y, radius.x);
        canvas.setFillColor(activeColor);
        canvas.fillPath();
        canvas.moveTo(2, bf.rect.height / 2);
        canvas.lineTo(bf.rect.width / 3, bf.rect.height / 4);
        canvas.lineTo(bf.rect.width - 2, bf.rect.height / 4 * 3);
        canvas.setStrokeColor(checkColor);
        canvas.setLineWidth(2);
        canvas.strokePath();
      },
    ),
  );

  drawAppearance(
    context,
    bf,
    mat,
    name: '/Off',
    selected: !value,
    child!,
  );

  PdfAnnot(
    context.page,
    bf,
    objser: replaces?.ser,
    objgen: replaces?.gen ?? 0,
  );
}