onGenerateRoute method
The route generator callback used when the app is navigated to a named route. Set it on the MaterialApp.onGenerateRoute or WidgetsApp.onGenerateRoute to make use of the paths for route matching.
Implementation
Route<dynamic>? onGenerateRoute(RouteSettings settings) {
logger.log(
'route: ${settings.name}, args: ${settings.arguments.runtimeType}(${settings.arguments})',
);
final _namedNavigationPath = namedPaths[settings.name];
if (_namedNavigationPath != null) {
final _route = _createRoute(_namedNavigationPath, settings);
_lastGeneratedRoute = _route;
return _route;
}
for (final path in paths) {
final hasMatch = path.matcher(settings);
if (hasMatch) {
return _createRoute(path, settings);
}
}
// If no match was found, we let [WidgetsApp.onUnknownRoute] handle it.
return null;
}