PdfPageCountField constructor Null safety

PdfPageCountField(
  1. {PdfFont? font,
  2. PdfBrush? brush,
  3. Rect? bounds,
  4. bool? isSectionPageCount}
)

Initializes a new instance of the PdfPageCountField class and may also with the classes are PdfFont, PdfBrush and Rect.

//Create a new pdf document
PdfDocument document = PdfDocument();
//Add the pages to the document
for (int i = 1; i <= 5; i++) {
  document.pages.add().graphics.drawString(
      'page$i', PdfStandardFont(PdfFontFamily.timesRoman, 11),
      bounds: Rect.fromLTWH(250, 0, 615, 100));
}
//Create the footer with specific bounds
PdfPageTemplateElement footer = PdfPageTemplateElement(
    Rect.fromLTWH(0, 0, document.pages[0].getClientSize().width, 50));
//Create the page count field
PdfPageCountField count = PdfPageCountField(
    font: PdfStandardFont(PdfFontFamily.timesRoman, 19),
    brush: PdfSolidBrush(PdfColor(0, 0, 0)));
//set the number style for page count
count.numberStyle = PdfNumberStyle.upperRoman;
//Create the composite field with page number page count
PdfCompositeField compositeField = PdfCompositeField(
    font: PdfStandardFont(PdfFontFamily.timesRoman, 19),
    brush: PdfSolidBrush(PdfColor(0, 0, 0)),
    text: 'Page Count: {0}',
    fields: <PdfAutomaticField>[count]);
compositeField.bounds = footer.bounds;
//Add the composite field in footer
compositeField.draw(
    footer.graphics,
    Offset(
        290, 50 - PdfStandardFont(PdfFontFamily.timesRoman, 19).height));
//Add the footer at the bottom of the document
document.template.bottom = footer;
//Save the document.
List<int> bytes = document.save();
//Dispose the document.
document.dispose();

Implementation

PdfPageCountField(
    {PdfFont? font, PdfBrush? brush, Rect? bounds, bool? isSectionPageCount})
    : super(font, brush, bounds) {
  _isSectionPageCount = isSectionPageCount != null && isSectionPageCount;
}