createStack method

RouteNode<RouteValue> createStack(
  1. RouteValue target, [
  2. Set<RouteValue> values = const {}
])

Implementation

RouteNode createStack(
  RouteValue target, [
  Set<RouteValue> values = const {},
]) {
  final HyperRoute? targetRoute = routeMap[target.key];

  if (targetRoute == null) {
    throw HyperError(
        "Route tree doesn't contain route with the provided key: ${target.key}");
  }

  final valuesMap = <Object, RouteValue>{};

  _stack?.forEach((builder) {
    valuesMap[builder.value.key] = builder.value;
  });
  valuesMap[target.key] = target;
  valuesMap.addAll(Map.fromIterable(
    values,
    key: (element) => element.key,
  ));

  final popCompleters = <Object, Completer>{};
  _stack?.forEach((node) {
    popCompleters[node.key] = node.popCompleter;
  });

  return targetRoute.createStack(
    values: valuesMap,
    popCompleters: popCompleters,
  )!;
}