defaultLayerIndex property

int defaultLayerIndex

Gets or sets index of the default layer (Read only).

//Create a new PDF documentation
PdfDocument document = PdfDocument();
//Create a new PDF page and gets the default layer index
int layerIndex = document.pages.add().defaultLayerIndex;
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();

Implementation

int get defaultLayerIndex {
  if (layers.count == 0 || _defaultLayerIndex == -1) {
    final PdfPageLayer layer = layers.add();
    _defaultLayerIndex = layers.indexOf(layer);
  }
  return _defaultLayerIndex;
}