canPop property

bool? canPop
final

When false, blocks the current route from being popped.

This includes the root route, where upon popping, the Flutter app would exit.

If multiple PopScope widgets appear in a route's widget subtree, then each and every canPop must be true in order for the route to be able to pop.

Android's predictive back feature will not animate when this boolean is false.

{@tool dartpad} This sample demonstrates how to use this parameter to show a confirmation dialog when a navigation pop would cause form data to be lost.

** See code in examples/api/lib/widgets/form/form.1.dart ** {@end-tool}

See also:

Implementation

final bool? canPop;