handlePopRoute method

  1. @protected
Future<void> handlePopRoute ()
@protected

Called when the system pops the current route.

This first notifies the binding observers (using WidgetsBindingObserver.didPopRoute), in registration order, until one returns true, meaning that it was able to handle the request (e.g. by closing a dialog box). If none return true, then the application is shut down by calling SystemNavigator.pop.

WidgetsApp uses this in conjunction with a Navigator to cause the back button to close dialog boxes, return from modal pages, and so forth.

This method exposes the popRoute notification from SystemChannels.navigation.

Implementation

@protected
Future<void> handlePopRoute() async {
  for (final WidgetsBindingObserver observer in List<WidgetsBindingObserver>.from(_observers)) {
    if (await observer.didPopRoute())
      return;
  }
  SystemNavigator.pop();
}