canReuse method
Called by the router to indicate if a component canReuse.
The client should return a future that completes with the whether the componentInstance should be reused. If the component extends the CanReuse lifecycle, that will override this behavior.
You can use async
in order to simplify when returning synchronously:
class MyHook extends RouterHook {
@override
Future<bool> canReuse(
Object _, RouterState __, RouterState ___) async {
// Make the default behavior to always reuse the component.
return true;
}
}
Implementation
Future<bool> canReuse(Object componentInstance, RouterState oldState,
RouterState newState) async {
// Provided as a default if someone extends or mixes-in this interface.
return false;
}