mt-akar / bottom_nav_layout

A quick and powerful Flutter layout with a bottom navbar.
https://pub.dev/packages/bottom_nav_layout
MIT License
35 stars 11 forks source link

Pushing Page from Application's Root Navigator Removes all Previous Routes #13

Closed Colton127 closed 2 years ago

Colton127 commented 2 years ago

Excellent plugin, and my apologies if this is a general Flutter inquiry not related to this package specifically.

I want to have a page which can be pushed from anywhere in the app. The page is a full-screen pop-up dialog, and I do not want the bottom bar to appear on this page. However, I want the user to be able to pop from the dialog back to the position they were at (tab selected, page, etc.)

I am using RootNavigator = true within my Navigator.push to accomplish this. However, when I use push a page from the root context, all my previous routes (the entirety of bottom_nav_layout routes) are immediately disposed.

This became an even more apparent issue with a video plugin which uses rootNavigator for full-screen. Opening a video in full screen from the root context (to hide the bottombar) disposes the entirety of the bottom bar all together. Thus, when the user exits full screen, the app goes back to the very home of bottomNavLayout, not the video page they were at.

As a temporary solution for the above, I had fullscreen open without root navigator, and hid the bottomBar using a changeNotifier. Still not the best solution.

I want to be able to push a page directly on top of the entire navigation stack - independent of the bottombar - and return later with the navigator preserved.

Thank you for your time.

mt-akar commented 2 years ago

Thank you for using the library and for contacting me.

As you reckon, the problem you are facing, as far as I understand, has nothing to do with this library. You are losing the bottom nav layout's routes because the layout's state is lost. What you are trying to achieve is state preservation between Navigator routes.

I think the IndexedStack widget can solve your problem easily, however, I am not sure if its the best solution in your specific situation.

It is best if you check out other SO posts related to this or create a post with a title like "How to preserve state between routes?".

Please tell me if you want to add anything or figured something out.

mt-akar commented 2 years ago

I hope you solved your problem @Colton127

I am closing this issue due to inactivity.