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

  final g = bf.appearance(context.document, PdfAnnotAppearance.normal,
      name: '/Yes', selected: value);
  g.drawRect(0, 0, bf.rect.width, bf.rect.height);
  g.setFillColor(activeColor);
  g.fillPath();
  g.moveTo(2, bf.rect.height / 2);
  g.lineTo(bf.rect.width / 3, bf.rect.height / 4);
  g.lineTo(bf.rect.width - 2, bf.rect.height / 4 * 3);
  g.setStrokeColor(checkColor);
  g.setLineWidth(2);
  g.strokePath();

  bf.appearance(context.document, PdfAnnotAppearance.normal,
      name: '/Off', selected: !value);

  PdfAnnot(context.page, bf);
}