insert method
Inserts page at position index.
The PdfPage constructor already registers the page in
document.pdfPageList.pages; that is why a page already in the collection
is moved to index instead of duplicated. For a second copy use
duplicate.
Implementation
void insert(int index, PdfPage page) {
_checkOwner(page);
_checkInsertIndex(index);
final before = List<PdfPage>.of(_pages);
final current = indexOf(page);
if (current >= 0) {
_pages.removeAt(current);
_pages.insert(index > current ? index - 1 : index, page);
} else {
_pages.insert(index, page);
}
_afterMutation(before);
}