insertPage method

dynamic insertPage(
  1. StatefulWidget newPage, {
  2. bool? goToNewPage = true,
  3. bool? ignoreTabHistory = false,
  4. bool? hideBottomNavigationBar,
})

Implementation

insertPage(
  StatefulWidget newPage, {
  bool? goToNewPage = true,
  bool? ignoreTabHistory = false,
  bool? hideBottomNavigationBar,
}) {
  if (goToNewPage == null) {
    goToNewPage = true;
  }
  //this.pages.add(newPage);
  this.pages.insert(_currentPageIndex + 1, newPage);

  if (hideBottomNavigationBar != null) {
    if (hideBottomNavigationBar == true) {
      this._hideBottomNavigationBar = true;
    } else {
      this._hideBottomNavigationBar = false;
    }
  }

  //this.pages.insert(_currentPageIndex + 1, newPage);
  if (ignoreTabHistory == null || ignoreTabHistory == false) {
    pageHistoryTabSelected.add(pageHistoryTabSelected.length > 0
        ? pageHistoryTabSelected[pageHistoryTabSelected.length - 1]
        : 0);
  }
  this
      ._onInsertPageListeners
      .forEach((func) => func(newPage, _currentPageIndex + 1));
  if (goToNewPage) {
    goToPage(_currentPageIndex + 1,
        animated: ignoreTabHistory == false,
        dontUpdateHistoryTabSelected: true);
  } else {
    this
        ._onBottomNavigationBarChanged
        .forEach((func) => func(this.currentBottomIndex));
    this._onListener.forEach((func) => func());
  }
}