jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
MIT License
10.33k stars 1.62k forks source link

Null check operator used on a null value when deep linking added #3040

Open AbirAppDevs opened 7 months ago

AbirAppDevs commented 7 months ago

Describe the bug Deep Linking I working on deep link, it is working fine without getx, and when i use getx if not close app it is working, but when i close the app it is showing errors.

image image image

Reproduction code NOTE: THIS IS MANDATORY, IF YOUR ISSUE DOES NOT CONTAIN IT, IT WILL BE CLOSED PRELIMINARY)

/// main file 
void main() async {
  ....
  ...
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(414, 896),
      builder: (_, child) => GetMaterialApp(
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          textTheme: ThemeData.light().textTheme.apply(
                fontFamily: 'Roboto',
              ),
          bottomSheetTheme:
              const BottomSheetThemeData(backgroundColor: Colors.transparent),
        ),
        initialRoute: Routes.splashScreen,
        getPages: Routes.list,
        navigatorKey: Get.key,
        initialBinding: BindingsBuilder(() async{
          Get.put(SettingController(), permanent: true);
          await DynamicLanguage.init(url: ApiEndpoint.languageURL);
        }),
        builder: (context, widget) {
          ScreenUtil.init(context);
          return Obx(
            () => MediaQuery(
              data: MediaQuery.of(context)
                  .copyWith(textScaler: TextScaler.linear(1.0)),
              child: Directionality(
                textDirection: DynamicLanguage.isLoading
                    ? TextDirection.ltr
                    : DynamicLanguage.languageDirection,
                child: widget!,
              ),
            ),
          );
        },
      ),
    );
  }
}

/// route
static var list = [
    GetPage(
      name: splashScreen,
      page: () => const SplashScreen(),
      binding: SplashBinding(),
    ),

    GetPage(
        name: '/details/values/:pathdId',
        page: () => DeepLinkScreen(id: Get.parameters["pathdId"] ?? "")
    ),
]

Video https://drive.google.com/file/d/1c9MU7EHmcevsEp2pNr-8Ny4kjPGKlYde/view?usp=sharing

*Screenshots deep link when Close App image

Flutter Version: (sdk: '>=3.2.5 <4.1.0')

Getx Version: (get: 4.6.6)

AbirAppDevs commented 7 months ago

adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d http://exampletest.com/details/values/12436892nece net.appdevs.walletium

I am testing deep link by command

Please guide me how to solve this error?

My WhatsApp Number +8801877348044 Email: abir.appdevs@gmail.com

LidiiaPl commented 7 months ago

I'm facing the same error currently. Any updates?

AbirAppDevs commented 7 months ago

No havent find any solution it is maybe from getx,, i am using uni links for getx now it is working on emulator but not in real device in release version LidiiaPl

AbirAppDevs commented 7 months ago
        <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />

i found that for this it is showing this error.. if i remove this .. it is okay

Sarathlal13 commented 7 months ago

Same issue here ═══════ Exception caught by widgets library ═══════════════════════════════════ The following _TypeError was thrown building _FocusInheritedScope: Null check operator used on a null value

The relevant error-causing widget was: Directionality Directionality:file:///Users/mac/.pub-cache/hosted/pub.dev/get-4.6.6/lib/get_navigation/src/root/get_material_app.dart:328:12

When the exception was thrown, this was the stack:

0 PageRedirect.page (package:g

nandakista commented 7 months ago

Hello guys, I have same issue in my old projects after spending a lot of time I found two the solutions that you can choose

  1. Make sure the initialRoute name is '/' or
  2. When the deeplink came from cold start, its always open the '/' as initial route and if your initial route name is not '/', getx throw to the unknown route property so you must set unknownRoute in the GetMaterialApp
    See the code hereScreenshot 2024-03-02 at 21 04 32

Hope this help you guys @AbirAppDevs @Sarathlal13

AbirAppDevs commented 7 months ago

@nandakista Thanks a Lot my dear...