Add RouteLogger to observe route information

Introduced a RouteLogger class implementing WidgetsBindingObserver to log incoming route information. Replaced the previous onRouteInformationUpdated handler with the observer pattern for improved route logging.
This commit is contained in:
Feodor Fitsner 2025-12-22 14:48:14 -08:00
parent 3389845651
commit 2b517bed69
1 changed files with 12 additions and 5 deletions

View File

@ -67,13 +67,20 @@ String assetsDir = "";
String appDir = "";
Map<String, String> environmentVariables = {};
class RouteLogger with WidgetsBindingObserver {
@override
Future<bool> didPushRouteInformation(
RouteInformation routeInformation,
) async {
debugPrint('📩 routeInformation: ${routeInformation.uri}');
return false; // return true only if YOU handled it and don't want default handling
}
}
void main(List<String> args) async {
PlatformDispatcher.instance.onRouteInformationUpdated =
(RouteInformation routeInformation) {
// This logs every incoming route/deeplink from the platform
print('📩 routeInformation: ${routeInformation.uri}');
};
WidgetsFlutterBinding.ensureInitialized();
WidgetsBinding.instance.addObserver(RouteLogger());
_args = List<String>.from(args);