navigationPath method
Called by the router to transform the path before a route navigation.
The client should return a future that completes with the desired new path for a specified route navigation.
You can use async
in order to simplify when returning synchronously:
class MyHook extends RouterHook {
@override
Future<String> navigationPath(String _, NavigationParams __) async {
// Maybe there is only a homepage, so redirect all to homepage.
return '';
}
}
Implementation
Future<String> navigationPath(String path, NavigationParams params) async {
// Provided as a default if someone extends or mixes-in this interface.
return path;
}