bounds property Null safety

Rect bounds

Gets or sets the bounds of the field.

//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 header with specific bounds
PdfPageTemplateElement header = PdfPageTemplateElement(
    Rect.fromLTWH(0, 0, document.pages[0].getClientSize().width, 300));
//Create the date and time field
PdfDateTimeField dateAndTimeField = PdfDateTimeField(
    font: PdfStandardFont(PdfFontFamily.timesRoman, 19),
    brush: PdfSolidBrush(PdfColor(0, 0, 0)));
dateAndTimeField.date = DateTime(2020, 2, 10, 13, 13, 13, 13, 13);
dateAndTimeField.dateFormatString = 'E, MM.dd.yyyy';
//Create the composite field.
PdfCompositeField compositefields = PdfCompositeField();
//Gets or sets the bounds.
compositefields.bounds = Rect.fromLTWH(10, 10, 200, 200);
//Gets or sets the font.
compositefields.font = PdfStandardFont(PdfFontFamily.timesRoman, 19);
//Gets or sets the brush.
compositefields.brush = PdfSolidBrush(PdfColor(0, 0, 0));
//Gets or sets the text.
compositefields.text = '{0}      Header';
//Gets or sets the fields.
compositefields.fields = <PdfAutomaticField>[dateAndTimeField];
//Add composite field in header
compositefields.draw(header.graphics,
    Offset(0, 50 - PdfStandardFont(PdfFontFamily.timesRoman, 11).height));
//Add the header at top of the document
document.template.top = header;
//Save the document.
List<int> bytes = document.save();
//Dispose the document.
document.dispose();

Implementation

Rect get bounds {
  return _bounds.rect;
}
void bounds=(Rect value)

Implementation

set bounds(Rect value) {
  _bounds = _Rectangle.fromRect(value);
}