push method
void
push(
- int pageIndex
)
override
Implementation
void push(int pageIndex) {
// Check if the last index is pushed again
if (pageIndex == last)
throw Exception("pageIndex pushed cannot be the same as the last index.");
// If the the item pushed is not the first item
if (pageIndex != first)
// If the pushed item exist on the stack, remove it
remove(pageIndex);
// If the index pushed is the first index,
else {
// Remove it up to two times.
this
..remove(pageIndex)
..remove(pageIndex);
// Add it back to the first spot
addFirst(pageIndex);
}
// Add index
addLast(pageIndex);
}