in nav2-usability/scenario_code/lib/skipping-stacks/router.dart [145:176]
Future<AppRoutePath> parseRouteInformation(
RouteInformation routeInformation) async {
final uri = Uri.parse(routeInformation.location!);
// Handle '/'
if (uri.pathSegments.isEmpty) {
return AppRoutePath();
}
if (uri.pathSegments.length == 2) {
// Handle '/book/:id'
if (uri.pathSegments[0] == 'book') {
final remaining = uri.pathSegments[1];
final id = int.tryParse(remaining);
if (id != null) {
return BookRoutePath(id);
}
// Handle '/author/:id'
} else if (uri.pathSegments[0] == 'author') {
final remaining = uri.pathSegments[1];
final id = int.tryParse(remaining);
if (id != null) {
return AuthorRoutePath(id);
}
}
} else if (uri.pathSegments.length == 1 &&
uri.pathSegments[0] == 'authors') {
return AuthorsRoutePath();
}
// Handle unknown routes
return AppRoutePath();
}