From 60a7af735a11c45319ee863dc60ac1a67f8078d8 Mon Sep 17 00:00:00 2001 From: FaizHashmi Date: Wed, 30 Sep 2026 09:26:26 +0300 Subject: [PATCH] Bug Fixes --- android/app/src/main/AndroidManifest.xml | 13 +++++++- lib/main.dart | 39 ++++++++++++++++++++++-- pubspec.yaml | 8 ++--- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8482224..2ab87e2 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -39,7 +39,7 @@ android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:exported="true" android:hardwareAccelerated="true" - android:launchMode="singleTop" + android:launchMode="singleTask" android:theme="@style/LaunchTheme" android:windowSoftInputMode="adjustResize"> + diff --git a/lib/main.dart b/lib/main.dart index df98301..95a9c1c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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 { 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 route; + route = PageRouteBuilder( + 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; + }, ), ); }, ); } } - - diff --git a/pubspec.yaml b/pubspec.yaml index b46332d..e9bfebe 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,10 +36,10 @@ dependencies: cupertino_icons: ^1.0.2 mc_common_app: -# path: /Users/faiz-hashmi/StudioProjects/mowater_apps/car_common_app -# path: /Volumes/Data/Projects/Flutter_Projects/mowater_apps/car_common_app -# path: /Users/faizhashmi/Development/Projects/MyProjects/CloudSolutions/car_common_app - path: ../car_common_app + # path: /Users/faiz-hashmi/StudioProjects/mowater_apps/car_common_app + # path: /Volumes/Data/Projects/Flutter_Projects/mowater_apps/car_common_app + # path: /Users/faizhashmi/Development/Projects/MyProjects/CloudSolutions/car_common_app + path: ../car_common_app