canPop property
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.
This sample demonstrates how to use this parameter to show a confirmation
dialog when a navigation pop would cause form data to be lost.
link
To create a local project with this code sample, run:
flutter create --sample=widgets.Form.canPop.1 mysample
See also:
- onPopInvokedWithResult, which also comes from PopScope and is often used in conjunction with this parameter.
- PopScope.canPop, which is what Form delegates to internally.
Implementation
final bool? canPop;