add method Null safety

PdfBookmark add(
  1. String title,
  2. {bool isExpanded = false,
  3. PdfColor? color,
  4. PdfDestination? destination,
  5. PdfNamedDestination? namedDestination,
  6. PdfAction? action,
  7. List<PdfTextStyle>? textStyle}
)

Adds the bookmark from the document.

//Create a new document.
PdfDocument document = PdfDocument();
//Add bookmarks to the document.
document.bookmarks.add('Page 1')
  ..destination = PdfDestination(document.pages.add(), Offset(20, 20))
  ..textStyle = [PdfTextStyle.bold]
  ..color = PdfColor(255, 0, 0);
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();

Implementation

PdfBookmark add(String title,
    {bool isExpanded = false,
    PdfColor? color,
    PdfDestination? destination,
    PdfNamedDestination? namedDestination,
    PdfAction? action,
    List<PdfTextStyle>? textStyle}) {
  final PdfBookmark? previous = (count < 1) ? null : this[count - 1];
  final PdfBookmark outline =
      PdfBookmark._internal(title, this, previous, null);
  if (previous != null) {
    previous._next = outline;
  }
  _list.add(outline);
  _updateFields();
  return outline;
}