Getx: NestedNavigation not working on version 3.0

Created on 27 Jun 2020  ยท  8Comments  ยท  Source: jonataslaw/getx

When I update GetX to version 3.0.1, nested navigation stop working. I already update GetRouteBase to GetPageRoute.

my navigator

return Navigator(
      key: Get.nestedKey(HomeTabRouter.navigatorIndex),
      onGenerateRoute: HomeTabRouter.onGenerateRoute,
    );
 ```

```dart 
static Route onGenerateRoute(RouteSettings settings) {
    if (settings.name == homeRoute)
      return GetPageRoute(
        page: () => HomePage(),
        binding: HomePageBindings(),
      );

    if (settings.name == categoriaRoute)
      return GetPageRoute(
        page: () => CategoriaPage(
          categoria: settings.arguments,
          navigatorId: navigatorIndex,
        ),
        binding: CategoriaPageBindings(),
      );

    if (settings.name == searchRoute)
      return GetPageRoute(
        page: () => SearchPage(
          navigatorId: navigatorIndex,
          query: settings.arguments,
        ),
        binding: SearchPageBindings(),
      );

    throw Exception('pagina nao encontrada: ${settings.name}');
  }

โ•โ•โ•ก EXCEPTION CAUGHT BY WIDGETS LIBRARY โ•žโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
I/flutter (16171): The following NoSuchMethodError was thrown building Builder(dirty):
I/flutter (16171): The getter 'name' was called on null.
I/flutter (16171): Receiver: null
I/flutter (16171): Tried calling: name
I/flutter (16171):
I/flutter (16171): The relevant error-causing widget was:
I/flutter (16171): Navigator-[LabeledGlobalKey#fb713]
I/flutter (16171): file:///F:/dev/wit/app_mbora/lib/src/features/home/pages/tab_home/tab_home.dart:9:12
I/flutter (16171):
I/flutter (16171): When the exception was thrown, this was the stack:
I/flutter (16171): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
I/flutter (16171): #1 new GetPageRoute. (package:get/src/routes/default_route.dart:49:47)
I/flutter (16171): #2 PageRouteBuilder.buildPage (package:flutter/src/widgets/pages.dart:101:23)
I/flutter (16171): #3 _ModalScopeState.build. (package:flutter/src/widgets/routes.dart:805:43)
I/flutter (16171): #4 Builder.build (package:flutter/src/widgets/basic.dart:7029:48)
I/flutter (16171): #5 StatelessElement.build (package:flutter/src/widgets/framework.dart:4618:28)
I/flutter (16171): #6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4544:15)
I/flutter (16171): #7 Element.rebuild (package:flutter/src/widgets/framework.dart:4260:5)
I/flutter (16171): #8 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4523:5)
I/flutter (16171): #9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4518:5)
I/flutter (16171): ... Normal element mounting (106 frames)
I/flutter (16171): #115 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3488:14)
I/flutter (16171): #116 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5989:32)
I/flutter (16171): ... Normal element mounting (70 frames)
I/flutter (16171): #186 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3488:14)
I/flutter (16171): #187 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5989:32)
I/flutter (16171): ... Normal element mounting (203 frames)
I/flutter (16171): #390 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3488:14)
I/flutter (16171): #391 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5989:32)
I/flutter (16171): ... Normal element mounting (254 frames)
I/flutter (16171): #645 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3488:14)
I/flutter (16171): #646 Element.updateChild (package:flutter/src/widgets/framework.dart:3256:18)
I/flutter (16171): #647 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1132:16)
I/flutter (16171): #648 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1103:5)
I/flutter (16171): #649 RenderObjectToWidgetAdapter.attachToRenderTree. (package:flutter/src/widgets/binding.dart:1045:17)
I/flutter (16171): #650 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2618:19)
I/flutter (16171): #651 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1044:13)
I/flutter (16171): #652 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:925:7)
I/flutter (16171): #653 WidgetsBinding.scheduleAttachRootWidget. (package:flutter/src/widgets/binding.dart:906:7)
I/flutter (16171): (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
I/flutter (16171):
I/flutter (16171): โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•`

Most helpful comment

I updated my example with working code.
I haven't used onGenerateRoute for so long that I forgot that it inherits name from settings.

All 8 comments

although jonatas can understand portuguese normally, it is recommended to make issues in English. The reason is that this package has a lot of users that are not brazilians, and those same users maybe will need to read your issue solution in order to solve their issue.

but jonatas didn't said that, that's my opinion only

@Nipodemos Agreed with you. I hope all issues can be in English. So all users can get the benefit from that.

What do you think @jonataslaw ?

Name your route, or it won't work.

if (settings.name == homeRoute)
      return GetPageRoute(
        settings: settings,
        page: () => HomePage(),
        binding: HomePageBindings(),
      );

    if (settings.name == categoriaRoute)
      return GetPageRoute(
       settings: settings,
        page: () => CategoriaPage(
          categoria: settings.arguments,
          navigatorId: navigatorIndex,
        ),
        binding: CategoriaPageBindings(),
      );

    if (settings.name == searchRoute)
      return GetPageRoute(
       settings: settings,
        page: () => SearchPage(
          navigatorId: navigatorIndex,
          query: settings.arguments,
        ),
        binding: SearchPageBindings(),
      );

although jonatas can understand portuguese normally, it is recommended to make issues in English. The reason is that this package has a lot of users that are not brazilians, and those same users maybe will need to read your issue solution in order to solve their issue.

but jonatas didn't said that, that's my opinion only

I think it is preferable to open an issue in English, but if it is an emergency or absence of the Google translator, it can be opened in another language, but even to avoid duplicate issues in different languages, English is preferable.

Name your route, or it won't work.

if (settings.name == homeRoute)
      return GetPageRoute(
        name: homeRoute,
        page: () => HomePage(),
        binding: HomePageBindings(),
      );

    if (settings.name == categoriaRoute)
      return GetPageRoute(
        name: categoriaRoute,
        page: () => CategoriaPage(
          categoria: settings.arguments,
          navigatorId: navigatorIndex,
        ),
        binding: CategoriaPageBindings(),
      );

    if (settings.name == searchRoute)
      return GetPageRoute(
        name: searchRoute,
        page: () => SearchPage(
          navigatorId: navigatorIndex,
          query: settings.arguments,
        ),
        binding: SearchPageBindings(),
      );

there's no name property on GetPageRoute

I updated my example with working code.
I haven't used onGenerateRoute for so long that I forgot that it inherits name from settings.

now it works perfectly

Why this is not working still? I literally copy pasted the example code. I am pushing pages with Get.to() and it seems like it does not recognize the nested route settings at all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

R-Praveen picture R-Praveen  ยท  4Comments

Nipodemos picture Nipodemos  ยท  4Comments

jemariads picture jemariads  ยท  4Comments

Denilson-source picture Denilson-source  ยท  3Comments

rupamking1 picture rupamking1  ยท  3Comments