Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

replaceLastName with nested navigation #153

Open
BarashkovaElena opened this issue Aug 15, 2024 · 0 comments
Open

replaceLastName with nested navigation #153

BarashkovaElena opened this issue Aug 15, 2024 · 0 comments

Comments

@BarashkovaElena
Copy link

I cannot figure out how to make replaceLastName work with nested navigation, need some help on that.
There is a root navigator and a a nested navigator. I want to open a page inside a tab in the nested navigator and then replace it with another page. I perform the following steps:

  1. Open nested navigation page. Stack tree initially looks like this:
Key [-1] (Root)
Key [2] (bottom_bar_page)

Key [20] (bottom_bar_page)
Key [3] (home)
  1. Open nested page over the home tab. Stack tree becomes this:
Key [-1] (Root)
Key [2] (bottom_bar_page)

Key [20] (bottom_bar_page)
Key [3] (home)
Key [4] (internal)
  1. Call QR.navigatorOf(bottomBarPageName).replaceLastName(dtoPageName);
    Stack tree becomes this:
Key [-1] (Root)
Key [2] (bottom_bar_page)

Key [20] (bottom_bar_page)
Key [4] (internal)
Key [3] (home)
Key [6] (dto)

This is not correct, because "internal" page should not be in the stack. It should contain only "home" and "dto".
I need to get this stack:

Key [-1] (Root)
Key [2] (bottom_bar_page)

Key [20] (bottom_bar_page)
Key [3] (home)
Key [6] (dto)

If I call replaceLastNamed on the root navigation, then the app crashes:

#2      NavigatorState.initState (package:flutter/src/widgets/navigator.dart:3577:14)
#3      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5618:55)
#4      ComponentElement.mount (package:flutter/src/widgets/framework.dart:5463:5)
...     Normal element mounting (48 frames)
#52     Element.inflateWidget (package:flutter/src/widgets/framework.dart:4340:16)
#53     MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6904:36)
#54     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6916:32)
...     Normal element mounting (380 frames)
#434    Element.inflateWidget (package:flutter/src/widgets/framework.dart:4340:16)
#435    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6904:36)
#436    Element.updateChild (package:flutter/src/widgets/framework.dart:3849:18)
#437    Element.updateChildren (package:flutter/src/widgets/framework.dart:4036:32)
#438    MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6929:17)
#439    Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#440    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#441    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5650:11)

How to get the desired stack tree?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant