canDeactivate method
Called by the router when a transition is requested between router states.
The client should return a future that completes with true
in order to
accept the transition, or completes with false
in order to reject it
(and prevent the routing from occurring).
class MyComponent implements CanDeactivate {
@override
Future<bool> canDeactivate(
RouterState current,
RouterState next,
) async =>
current.parameters['id'] != next.parameters['id'];
}
This lifecycle occurs before CanActivate.canActivate
.
Implementation
Future<bool> canDeactivate(RouterState current, RouterState next) async {
// Provided as a default if someone extends or mixes-in this interface.
return true;
}