pageSettings property Null safety

PdfPageSettings pageSettings

Gets the document's page setting.

//Create a PDF document instance.
PdfDocument document = PdfDocument();
//Get the document page settings.
document.pageSettings.margins.all = 50;
//Create page and draw text.
document.pages.add().graphics.drawString(
    'Hello World!', PdfStandardFont(PdfFontFamily.helvetica, 12),
    brush: PdfBrushes.black, bounds: Rect.fromLTWH(0, 0, 0, 0));
//Save and dispose document.
List<int> bytes = await document.save();
document.dispose();

Implementation

PdfPageSettings get pageSettings {
  if (_settings == null) {
    _settings = PdfPageSettings();
    _settings!.setMargins(PdfDocumentHelper.defaultMargin);
  }
  return _settings!;
}
void pageSettings=(PdfPageSettings settings)

Sets the document's page setting.

//Create a PDF document instance.
PdfDocument document = PdfDocument();
//Create a PDF page settings.
PdfPageSettings settings = PdfPageSettings();
settings.margins.all = 50;
//Set the page settings to document.
document.pageSettings = settings;
//Create page and draw text.
document.pages.add().graphics.drawString(
    'Hello World!', PdfStandardFont(PdfFontFamily.helvetica, 12),
    brush: PdfBrushes.black, bounds: Rect.fromLTWH(0, 0, 0, 0));
//Save and dispose document.
List<int> bytes = await document.save();
document.dispose();

Implementation

set pageSettings(PdfPageSettings settings) {
  _settings = settings;
}