pop method

bool pop({
  1. Route? route,
  2. dynamic result,
  3. PageArgs? pageArgs,
  4. PageBuilder? pageBuilder,
})

Pops the current page from the stack and returns the result of the pop. The page's onPopPage callback will fire when this happens.

Implementation

bool pop({
  final Route<dynamic>? route,
  // ignore: avoid_annotating_with_dynamic
  dynamic result,
  PageArgs<dynamic>? pageArgs,
  PageBuilder<dynamic>? pageBuilder,
}) {
  //TODO: This method is pretty filthy. Clean it up.

  if (_pageStack.length < 2) {
    return false;
  }

  var pop = false;

  if (route == null) {
    pop = _popNullRoute(pageArgs);
  } else {
    pop = pageBuilder!.onPopPage(route, result, pageArgs!);
    if (pop) {
      pageArgs.bloc.dispose();
    }
  }

  if (!pop) {
    return false;
  }

  //TODO: Log the popped page
  //ignore: avoid-ignoring-return-values
  _pageStack.pop();

  notifyListeners();

  return pop;
}