navigateTo method

dynamic navigateTo({
  1. required PanelKitPage page,
  2. dynamic data,
})

Implementation

navigateTo({required PanelKitPage page, dynamic data}) {
  if (_pages.contains(page)) {
    int index = _pages.indexOf(page) + 1;
    _pages.removeRange(index, _pages.length);
    if (index == 0) {
      Navigator.popUntil(navigatorKey.currentContext!, ModalRoute.withName("/"));
    } else {
      Navigator.popUntil(navigatorKey.currentContext!, ModalRoute.withName(_pages.last.routeId));
    }
  } else {
    _pages.add(page);
    Navigator.pushNamed(navigatorKey.currentContext!, _pages.last.routeId);
  }
}