pushOrReplacement<T extends Object?, TO extends Object?> method

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

Implementation

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

  if (_topRouteName == replaceRouteName) {
    newArguments['disableAnimate'] = true;
    return state.pushReplacementNamed<T, TO>(
      routeName,
      result: result,
      arguments: newArguments,
    );
  } else {
    return state.pushNamed<T>(
      routeName,
      arguments: newArguments,
    );
  }
}