navigate<T extends Object?> method

Future<T?> navigate<T extends Object?>(
  1. Location to, {
  2. bool? replace,
  3. bool? clearStack,
})

Pushes a new location to the current child's stack.

Implementation

Future<T?> navigate<T extends Object?>(
  Location to, {
  bool? replace,
  bool? clearStack,
}) async {
  Location? replaced;

  if (clearStack ?? false) {
    for (final l in currentRouterDelegate.currentConfiguration.locations) {
      widget.configuration.clearLocation(l);
    }
    currentRouterDelegate.currentConfiguration.locations.clear();
  } else if (replace ?? false) {
    replaced =
        currentRouterDelegate.currentConfiguration.locations.removeLast();
  }

  return _informationProviders[_currentIndex].navigate<T>(
    to,
    baseLocationStack: currentRouterDelegate.currentConfiguration,
    replaced: replaced,
  );
}