add static method
void
add(
- InterceptorFunction interceptorFunction, {
- bool ifNotYetIntercepted = false,
- int? zIndex,
- String? name,
- BuildContext? context,
Sets a function to be called when the back button is tapped. This function may perform some useful work, and then, if it returns true, the default button process (usually popping a Route) will not be fired.
Functions added last are called first.
If the optional ifNotYetIntercepted
parameter is true, then the function will only be
called if all previous functions returned false (that is, stopDefaultButtonEvent is false).
Optionally, you may provide a z-index. Functions with a valid z-index will be called before functions with a null z-index, and functions with larger z-index will be called first. When they have the same z-index, functions added last are called first.
Implementation
static void add(
InterceptorFunction interceptorFunction, {
bool ifNotYetIntercepted = false,
int? zIndex,
String? name,
BuildContext? context,
}) {
_interceptors.insert(
0,
_FunctionWithZIndex(
interceptorFunction,
ifNotYetIntercepted,
zIndex,
name,
context == null ? null : getCurrentNavigatorRoute(context),
));
stableSort(_interceptors);
SystemChannels.navigation.setMethodCallHandler(_handleNavigationInvocation);
}