Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[bug]: Route id (2) not found #909

Closed
felixjaehn opened this issue Mar 18, 2023 · 6 comments
Closed

[bug]: Route id (2) not found #909

felixjaehn opened this issue Mar 18, 2023 · 6 comments
Labels
documentation Issue to force documentation updates Feedback Requested Waiting for new information from the OP

Comments

@felixjaehn
Copy link

felixjaehn commented Mar 18, 2023

Describe the bug

I am trying to use a second nested navigation flow inside my stacked app. But when doing so it throws the exception: "Route id (2) not found".

To reproduce

My code in app.dart:

The nested navigation flow that is working:

 CupertinoRoute(page: CityInputNavigator, children: [
      CupertinoRoute(page: CityInputView, initial: true),
      CupertinoRoute(page: CityAddSubscriptionView),
      CupertinoRoute(page: UpdateSubscriptionSuccessView),
    ]),

The nested navigation flow that isn't working:

 CustomRoute(page: SubscriptionOverviewNavigator, children: [
      CustomRoute(page: SubscriptionOverviewView),
      CustomRoute(
        page: OfferFocusView,
        opaque: false,
        durationInMilliseconds: 212,
        reverseDurationInMilliseconds: 160,
        transitionsBuilder: CustomTransitionsBuilders.fadeIn,
      )
    ]),

The setup in the individual mainNavigatorPages:
The one that is working:

class CityInputNavigator extends StatelessWidget {
  const CityInputNavigator({super.key});

  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: sheetRadius,
      child: Material(
        borderRadius: sheetRadius,
        child: Container(
            decoration: const BoxDecoration(
              borderRadius: sheetRadius,
              color: Colors.white,
            ),
            child: ExtendedNavigator(router: CityInputNavigatorRouter(), navigatorKey: StackedService.nestedNavigationKey(1))),
      ),
    );
  }
}

The setup for the nested navigation that isn't working and throws the error mentioned above:

class SubscriptionOverviewNavigator extends StatelessWidget {
  const SubscriptionOverviewNavigator({super.key});

  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: sheetRadius,
      child: Material(
        borderRadius: sheetRadius,
        child: Container(
            decoration: const BoxDecoration(
              borderRadius: sheetRadius,
              color: Colors.white,
            ),
            child: ExtendedNavigator(
              router: SubscriptionOverviewNavigatorRouter(),
              key: StackedService.nestedNavigationKey(2),
              initialRoute: SubscriptionOverviewNavigatorRoutes.subscriptionOverviewView,
            )),
      ),
    );
  }
}

When now trying to navigate to a new nested route using:

_navigationService.navigateTo(SubscriptionOverviewNavigatorRoutes.offerFocusView,
        arguments: NestedOfferFocusViewArguments(color: color, heroTag: heroTag), id: 2);

it throws the error: Route id(2) not found

Route id (2) not found

When the exception was thrown, this was the stack:
#0 GetNavigation.global (package:get/get_navigation/src/extension_navigation.dart:1088:9)
#1 GetNavigation.toNamed (package:get/get_navigation/src/extension_navigation.dart:592:12)
#2 NavigationService.navigateTo (package:stacked_services/src/navigation/navigation_service.dart:204:18)
#3 SubscriptionOverviewViewModel.focusOfferDetails
(package:subscription_v2/cupertino_sheet_contents/subscription_overview/subscription_overview_viewmodel.dart:20:24)
#4 SubscriptionOverviewView.build..
(package:subscription_v2/cupertino_sheet_contents/subscription_overview/subscription_overview_view.dart:99:39)
#5 SubscriptionContainer.build.
(package:subscription_v2/cupertino_sheet_contents/subscription_overview/subscription_overview_view.dart:210:75)
#6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:253:24)
#7 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:627:11)
#8 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:306:5)
#9 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:276:7)
#10 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:163:27)
#11 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:464:20)
#12 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:440:22)
#13 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:336:11)
#14 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:395:7)
#15 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:357:5)
#16 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:314:7)
#17 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:295:7)
#18 _invoke1 (dart:ui/hooks.dart:164:13)
#19 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:361:7)
#20 _dispatchPointerDataPacket (dart:ui/hooks.dart:91:31)

Expected behavior

No response

Screenshots

No response

Additional Context

No response

@waza-ari
Copy link

By far not an expert, but shouldn't

key: StackedService.nestedNavigationKey(2),

be

navigatorKey: StackedService.nestedNavigationKey(2),

@felixjaehn
Copy link
Author

Thought that this would solve the problem, but sadly the issue still persists, even after changing key to navigatorKey.

@FilledStacks
Copy link
Contributor

Hi @felixjaehn I recently closed another issue like this. Which you can read through here. I gave a detailed answer which I think is the same one you're facing.

@FilledStacks FilledStacks added the Feedback Requested Waiting for new information from the OP label Mar 20, 2023
@waza-ari
Copy link

Are you maybe trying to jump to a nested route directly from "outside"? I made the experience that you need to jump to the parent page using the normal navigator, and can then jump within this environment using the nestedNavigationKey.

If this is true, it might be worth adding this to the documentation, I did stumble across this myself @FilledStacks

@FilledStacks
Copy link
Contributor

@waza-ari yes, that's what I'm thinking as well. @felixjaehn is trying to go to OfferFocusView which is inside the SubscriptionOvervIewView. The comment above should solve it , and @waza-ari we should definitely add it to the Stacked Docs. When I get some free time after releasing the new Flutter web series of Videos this week I might spend some time on the Stacked Docs.

@FilledStacks FilledStacks added the documentation Issue to force documentation updates label Mar 20, 2023
@felixjaehn
Copy link
Author

Thank you @waza-ari and @FilledStacks. The tip from @waza-ari solved it for me

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
documentation Issue to force documentation updates Feedback Requested Waiting for new information from the OP
Projects
None yet
Development

No branches or pull requests

3 participants