offAndToNamed<T> method

Future<T?>? offAndToNamed<T>(
  1. String page, {
  2. dynamic arguments,
  3. String? id,
  4. dynamic result,
  5. Map<String, String>? parameters,
})

Navigation.popAndPushNamed() shortcut.

Pop the current named page and pushes a new page to the stack in its place

You can send any type of value to the other route in the arguments. It is very similar to offNamed() but use a different approach

The offNamed() pop a page, and goes to the next. The offAndToNamed() goes to the next page, and removes the previous one. The route transition animation is different.

Implementation

Future<T?>? offAndToNamed<T>(
  String page, {
  dynamic arguments,
  String? id,
  dynamic result,
  Map<String, String>? parameters,
}) {
  if (parameters != null) {
    final Uri uri = Uri(path: page, queryParameters: parameters);
    page = uri.toString();
  }
  return searchDelegate(id).backAndtoNamed(
    page,
    arguments: arguments,
    result: result,
  );
}