build method Null safety

  1. @protected
  2. @mustCallSuper
void build(
  1. PdfPage page,
  2. PdfObject<PdfDataType> object,
  3. PdfDict<PdfDataType> params
)

Implementation

@protected
@mustCallSuper
void build(PdfPage page, PdfObject object, PdfDict params) {
  params['/Subtype'] = PdfName(subtype);
  params['/Rect'] =
      PdfArray.fromNum([rect.left, rect.bottom, rect.right, rect.top]);

  params['/P'] = page.ref();

  // handle the border
  if (border == null) {
    params['/Border'] = PdfArray.fromNum(const [0, 0, 0]);
  } else {
    params['/BS'] = border!.ref();
  }

  if (content != null) {
    params['/Contents'] = PdfSecString.fromString(object, content!);
  }

  if (name != null) {
    params['/NM'] = PdfSecString.fromString(object, name!);
  }

  if (flags != null && flags!.isNotEmpty) {
    params['/F'] = PdfNum(flagValue);
  }

  if (date != null) {
    params['/M'] = PdfSecString.fromDate(object, date!);
  }

  if (color != null) {
    params['/C'] = PdfColorType(color!);
  }

  if (subject != null) {
    params['/Subj'] = PdfSecString.fromString(object, subject!);
  }

  if (author != null) {
    params['/T'] = PdfSecString.fromString(object, author!);
  }

  if (_appearances.isNotEmpty) {
    params['/AP'] = PdfDict(_appearances);
    if (_as != null) {
      params['/AS'] = _as!;
    }
  }
}