In this case, it is using navigator 2. You need to extend RouteInformationParser and check pathSegments.
On your main class, App will return MaterialApp.router and need to provide routerDelegate and routeInformationParser.
return MaterialApp.router(
routeInformationParser: _routeInformationParser,
routerDelegate: _routerDelegate,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
);
_routeInformationParser will be extended from RouteInformationParser and _routerDelegate will extend RouterDelegate.
Based on https://example.app/500 it is having pathSegments.length == 2
If will be handled like
if (uri.pathSegments.length == 2) {
if (uri.pathSegments[0] != 'details') return AppRoutePath.unknown();// recheck
final id = int.tryParse(uri.pathSegments[1]);
if (id == null) return AppRoutePath.unknown();
return AppRoutePath.details(id);
}
You can find my practice demo here using navigator2. Also there are great packages for it like, auto_route as @Pratik Butani described , go_router etc.