|
|
|
|
@ -10,6 +10,7 @@ import 'package:mc_common_app/repositories/request_repo.dart';
|
|
|
|
|
import 'package:mc_common_app/repositories/setting_options_repo.dart';
|
|
|
|
|
import 'package:mc_common_app/services/ad_deep_link_service.dart';
|
|
|
|
|
import 'package:mc_common_app/services/firebase_service.dart';
|
|
|
|
|
import 'package:mc_common_app/views/splash/splash_page.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/location/Location.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/appointments_view_model.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/chat_view_model.dart';
|
|
|
|
|
@ -177,11 +178,45 @@ class _MyAppState extends State<MyApp> {
|
|
|
|
|
locale: context.locale,
|
|
|
|
|
initialRoute: AppRoutes.initialRoute,
|
|
|
|
|
routes: CustomerAppRoutes.routes,
|
|
|
|
|
navigatorObservers: [AdDeepLinkService.routeObserver],
|
|
|
|
|
// Confirmed on a real device, two different unknown-route cases land here:
|
|
|
|
|
// 1) Cold-start restoration can try to regenerate a bare "/" instead of
|
|
|
|
|
// respecting initialRoute -- uncaught, that's a "Could not find a generator
|
|
|
|
|
// for route" crash before AdDeepLinkService ever runs. Splash is a real,
|
|
|
|
|
// correct landing page for this one.
|
|
|
|
|
// 2) On an ALREADY-RUNNING app, Android's Flutter embedding auto-forwards the
|
|
|
|
|
// incoming deep-link intent's path as its own route push (e.g. "/1541" from
|
|
|
|
|
// mowatercustomer://ad/1541) independently of app_links/AdDeepLinkService,
|
|
|
|
|
// which already handles that same uri correctly. Since "/1541" isn't a real
|
|
|
|
|
// route, it used to fall into case 1 and push Splash right over whatever
|
|
|
|
|
// screen (e.g. the dashboard) was already showing -- looking exactly like the
|
|
|
|
|
// app had restarted. Anything other than bare "/" must be a no-op here: push
|
|
|
|
|
// something inert that removes itself immediately instead of a real page.
|
|
|
|
|
onUnknownRoute: (settings) {
|
|
|
|
|
if (settings.name == '/') {
|
|
|
|
|
return MaterialPageRoute(builder: (_) => const SplashPage());
|
|
|
|
|
}
|
|
|
|
|
// Remove THIS specific route once inserted, not just "whatever is on top" --
|
|
|
|
|
// AdDeepLinkService's own (legitimate) push can land after this one, and a
|
|
|
|
|
// plain Navigator.pop() would close that instead of this inert placeholder.
|
|
|
|
|
late final PageRoute<void> route;
|
|
|
|
|
route = PageRouteBuilder<void>(
|
|
|
|
|
settings: const RouteSettings(name: AdDeepLinkService.ignoredPlaceholderRouteName),
|
|
|
|
|
opaque: false,
|
|
|
|
|
transitionDuration: Duration.zero,
|
|
|
|
|
reverseTransitionDuration: Duration.zero,
|
|
|
|
|
pageBuilder: (context, __, ___) {
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
if (route.isActive) route.navigator?.removeRoute(route);
|
|
|
|
|
});
|
|
|
|
|
return const SizedBox.shrink();
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
return route;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|