clearTillFirstAndShow<T> method

Future<T?>? clearTillFirstAndShow<T>(
  1. String routeName, {
  2. dynamic arguments,
  3. int? id,
  4. bool preventDuplicates = true,
  5. Map<String, String>? parameters,
})

Pops the navigation stack until there's 1 view left then pushes routeName onto the stack

id is for when you are using nested navigation, as explained in documentation.

preventDuplicates will prevent you from pushing a route that you already in, if you want to push anyway, set to false.

Implementation

Future<T?>? clearTillFirstAndShow<T>(
  String routeName, {
  dynamic arguments,
  int? id,
  bool preventDuplicates = true,
  Map<String, String>? parameters,
}) {
  _clearBackstackTillFirst();

  return navigateTo<T?>(
    routeName,
    arguments: arguments,
    id: id,
    preventDuplicates: preventDuplicates,
    parameters: parameters,
  );
}