ITADN

App throws exception when launched from notification on Huawei devices if getPages is configured

#3438Openhengheng1220 创建于 2026-01-12
H
hengheng1220commented
During testing on Huawei devices, the app launches normally from the notification tray when GetMaterialApp is configured with the home parameter only. However, once getPages is configured, launching the app by tapping a notification from the notification bar causes the app to throw an exception. example: ```dart Widget build(BuildContext context) { debugPaintSizeEnabled = false; return ScreenUtilInit( designSize: const Size(375, 812), //750,1624 minTextAdapt: true, splitScreenMode: true, builder: (BuildContext context, Widget? child) => GetMaterialApp( getPages: AppRoutes.routes, theme: ThemeManager.to.lightTheme, darkTheme: ThemeManager.to.lightTheme, themeMode: ThemeManager.to.themeMode, translations: AppTranslations(), locale: LocaleManager.to.currentLocale, fallbackLocale: const Locale('zh', 'CN'), supportedLocales: LocaleManager.to.supportedLocales, localizationsDelegates: const [ GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], builder: (context, widget) { return MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(1.0)), child: FlutterEasyLoading( child: Stack( children: [ widget ?? SizedBox(), _buildMessageNotificationOverlay(context), ], ), ), ); }, navigatorKey: navigatorKey, debugShowCheckedModeBanner: false, initialRoute: AppRoutes.splash, initialBinding: SplashPageBinding(), routingCallback: (routing) {}, ), ); } ``` **To Reproduce** 1. Install the app on a Huawei device (Huawei nova 12, HarmonyOS 4.2.0). 2. Launch the app once normally to ensure it works. 3. Send or receive a system notification that opens the app when tapped. 4. Kill the app completely (cold start). 5. Tap the notification from the notification tray. 6. The app throws an exception during startup when `getPages` is configured. **Screenshots** The screenshots below show the exception and log output when the app is launched from a notification on a Huawei device. ![Image](https://github.com/user-attachments/assets/57d3c8e8-5770-49d2-8289-0d968ad2a64a) <img width="2121" height="690" alt="Image" src="https://github.com/user-attachments/assets/412fcf27-8756-43b4-934b-7fbceac7381a" /> **Environment:** Flutter 3.38.2 Device: Huawei nova 12 OS: HarmonyOS 4.2.0 get: ^4.7.3 **Minimal reproduce code** ```dart Widget build(BuildContext context) { debugPaintSizeEnabled = false; return ScreenUtilInit( designSize: const Size(375, 812), //750,1624 minTextAdapt: true, splitScreenMode: true, builder: (BuildContext context, Widget? child) => GetMaterialApp( // ❌ When this is enabled, launching from notification throws an exception getPages: AppRoutes.routes, // ✅ Works fine if getPages & initialRoute are removed // home: const SplashPage(), theme: ThemeManager.to.lightTheme, darkTheme: ThemeManager.to.lightTheme, themeMode: ThemeManager.to.themeMode, translations: AppTranslations(), locale: LocaleManager.to.currentLocale, fallbackLocale: const Locale('zh', 'CN'), supportedLocales: LocaleManager.to.supportedLocales, localizationsDelegates: const [ GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], builder: (context, widget) { return MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(1.0)), child: FlutterEasyLoading( child: Stack( children: [ widget ?? SizedBox(), _buildMessageNotificationOverlay(context), ], ), ), ); }, navigatorKey: navigatorKey, debugShowCheckedModeBanner: false, initialRoute: AppRoutes.splash, initialBinding: SplashPageBinding(), routingCallback: (routing) {}, ), ); } ``` This issue only occurs on Huawei devices. Other Android devices have not reproduced this problem so far.
0 条评论