getCurrentPageIndex method

  1. @override
int getCurrentPageIndex(
  1. Widget currentPage
)
override

Returns the index of the current page. The index corresponds to its position in the pages array passed to the initializeRoutes method of the initiator.

The index starts from 0.

This is added to provide more info about the current position of the page in the participator array.

This value is obtain by traversing the doubly-linked list data of all pages in the left direction until we reach the first element. This value is not cached as a static index value as we'd introduce the overhead of making sure that the index is always accurate. For example, if you use Navigator.pop instead of dynamicRoutesParticipator.popCurrent, the static number will not be accurate.

Implementation

@override
int getCurrentPageIndex(Widget currentPage) {
  return _getCurrentPageDLLData(currentPage)
      .getTraversalSteps(PageDLLTraversalDirection.left);
}