background property Null safety

bool background

Indicates whether the page template is located behind of the page layers or in front of it.

//Create a new pdf document
PdfDocument document = PdfDocument();
//Set margins.
document.pageSettings.setMargins(25);
//Create the page template with specific bounds
PdfPageTemplateElement custom = PdfPageTemplateElement(
    const Offset(5, 5) & const Size(110, 110), document.pages.add());
document.template.stamps.add(custom);
//Gets or sets  background.
custom.background = true;
//Draw template into pdf page.
custom.graphics.drawRectangle(
    pen: PdfPen(PdfColor(255, 165, 0), width: 3),
    brush: PdfSolidBrush(PdfColor(173, 255, 47)),
    bounds: Rect.fromLTWH(0, 0, 100, 100));
//Save the document.
List<int> bytes = document.save();
//Dispose the document.
document.dispose();

Implementation

bool get background => !foreground;
void background=(bool value)

Implementation

set background(bool value) {
  foreground = !value;
}