changeNavigationStack method

void changeNavigationStack([
  1. bool needInitialPathParams = false
])

Implementation

void changeNavigationStack([bool needInitialPathParams = false]) async {
  HypenNavigator? node = rootNav;
  final newRouteStack = <NavigationArgs>[];
  final router = GoRouter.of(context);

  while (node != null) {
    final args = node.createArgs();
    if (args != null) {
      newRouteStack.add(args);
    }
    node.pathParameters = needInitialPathParams
        ? router.routerDelegate.currentConfiguration.pathParameters
        : {};
    node = await node.build(context, this);
    node?.pathParameters = {};
  }

  if (!context.mounted) {
    return;
  }

  router.go(newRouteStack.last.path, extra: newRouteStack.last.extra);
}