maybePop<T extends Object> method

  1. @optionalTypeArgs
Future<bool> maybePop <T extends Object>([T result ])

Returns the value of the current route's Route.willPop method for the navigator.

This method is typically called before a user-initiated pop. For example on Android it's called by the binding for the system's back button.

The T type argument is the type of the return value of the current route.

See also:

  • Form, which provides an onWillPop callback that enables the form to veto a pop initiated by the app's back button.
  • ModalRoute, which provides a scopedWillPopCallback that can be used to define the route's willPop method.


Future<bool> maybePop<T extends Object>([ T result ]) async {
  final Route<T> route = _history.last;
  assert(route._navigator == this);
  final RoutePopDisposition disposition = await route.willPop();
  if (disposition != RoutePopDisposition.bubble && mounted) {
    if (disposition == RoutePopDisposition.pop)
    return true;
  return false;