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

  if (value != null) {
    context.document.sign ??= PdfSignature(
      context.document,
      value: value!,
      flags: {
        PdfSigFlags.signaturesExist,
        if (appendOnly) PdfSigFlags.appendOnly,
      },
      crl: crl,
      cert: cert,
      ocsp: ocsp,
    );
  } else {
    paintChild(context);
  }

  final bf = PdfAnnotSign(
    rect: context.localToGlobal(box!),
    fieldName: name,
    border: border,
    flags: flags,
    date: date,
    color: color,
    highlighting: highlighting,
  );

  if (child != null && value != null) {
    final mat = context.canvas.getTransform();
    final translation = Vector3(0, 0, 0);
    final rotation = Quaternion(0, 0, 0, 0);
    final scale = Vector3(0, 0, 0);
    mat
      ..decompose(translation, rotation, scale)
      ..leftTranslate(-translation.x, -translation.y)
      ..translate(box!.x, box!.y);

    final canvas = bf.appearance(context.document, PdfAnnotAppearance.normal,
        matrix: mat);
    Widget.draw(
      child!,
      offset: PdfPoint.zero,
      canvas: canvas,
      page: context.page,
      constraints:
          BoxConstraints.tightFor(width: box!.width, height: box!.height),
    );
  }

  PdfAnnot(context.page, bf);
}