remove method Null safety

void remove(
  1. String title
)

Remove the specified bookmark from the document.

//Load the PDF document.
PdfDocument document = PdfDocument(inputBytes: inputBytes);
//Get all the bookmarks.
PdfBookmarkBase bookmarks = document.bookmarks;
//Remove specified bookmark.
bookmarks.remove('bookmark');
//Save the document.
List<int> bytes = document.save();
//Dispose the document.
document.dispose();

Implementation

void remove(String title) {
  int index = -1;
  if (_bookmark == null || _bookmark!.length < _list.length) {
    _bookmark = <PdfBookmark>[];
    for (int n = 0; n < _list.length; n++) {
      if (_list[n] is PdfBookmark) {
        _bookmark!.add(_list[n] as PdfBookmark);
      }
    }
  }
  for (int c = 0; c < _bookmark!.length; c++) {
    if (_bookmark![c] is PdfBookmark) {
      final PdfBookmark pdfbookmark = _bookmark![c];
      if (pdfbookmark.title == title) {
        index = c;
        break;
      }
    }
  }
  removeAt(index);
}