pushAndRemoveUntil<T extends Object?> method

Future<T?> pushAndRemoveUntil<T extends Object?>(
  1. String newRouteName,
  2. String routeName, {
  3. Map<String, dynamic> arguments = const {},
  4. List<String> holdBlocNames = const [],
})

Implementation

Future<T?> pushAndRemoveUntil<T extends Object?>(
  String newRouteName,
  String routeName, {
  Map<String, dynamic> arguments = const {},
  List<String> holdBlocNames = const [],
}) {
  if (_isSameTopRoute(newRouteName, arguments)) {
    return Future.value();
  }
  Map<String, dynamic> newArguments = Map.from(arguments);
  newArguments['##holdBlocNames##'] = holdBlocNames;
  holdBlocNames.forEach(GlobalStore().pushState);

  return state.pushNamedAndRemoveUntil<T>(
    newRouteName,
    (route) => route.settings.name == routeName,
    arguments: newArguments,
  );
}