willPop method

  1. @Deprecated('Use popDisposition instead. ' 'This feature was deprecated after v3.12.0-1.0.pre.')
  2. @override
Future<RoutePopDisposition> willPop()

Returns whether calling Navigator.maybePop when this Route is current (isCurrent) should do anything.

Navigator.maybePop is usually used instead of Navigator.pop to handle the system back button.

By default, if a Route is the first route in the history (i.e., if isFirst), it reports that pops should be bubbled (RoutePopDisposition.bubble). This behavior prevents the user from popping the first route off the history and being stranded at a blank screen; instead, the larger scope is popped (e.g. the application quits, so that the user returns to the previous application).

In other cases, the default behavior is to accept the pop (RoutePopDisposition.pop).

The third possible value is RoutePopDisposition.doNotPop, which causes the pop request to be ignored entirely.

See also:

  • Form, which provides a Form.onWillPop callback that uses this mechanism.
  • WillPopScope, another widget that provides a way to intercept the back button.


  'Use popDisposition instead. '
  'This feature was deprecated after v3.12.0-1.0.pre.',
Future<RoutePopDisposition> willPop() async {
  if (willHandlePopInternally) {
    return RoutePopDisposition.pop;
  return super.willPop();