back method

void back({
  1. T? result,
  2. bool canPop = true,
  3. int times = 1,
  4. String? id,
})

Navigation.popUntil() shortcut.

Pop the current page in the stack

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

It has the advantage of not needing context, so you can call from your business logic.

Implementation

void back({
  T? result,
  bool canPop = true,
  int times = 1,
  String? id,
}) {
  if (times < 1) {
    times = 1;
  }

  if (times > 1) {
    int count = 0;
    return searchDelegate(id).backUntil((GetPage route) => count++ == times);
  } else {
    if (canPop) {
      if (searchDelegate(id).canBack) {
        return searchDelegate(id).back(result);
      }
    } else {
      return searchDelegate(id).back(result);
    }
  }
}