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

How to call dispose method in third screen. #10

Closed
anup-geeky opened this issue Apr 29, 2020 · 2 comments
Closed

How to call dispose method in third screen. #10

anup-geeky opened this issue Apr 29, 2020 · 2 comments

Comments

@anup-geeky
Copy link

@BilalShahid13 This library is superb. It solved my major design problem.
But give me solution of below scenario.
Let suppose in Home tab, I am in third screen and if I click search tab or any other tab then how to call dispose method in third screen. I want to close some connection in third screen.

How can I do that?

And also if I am on Home tab, go to second screen then how to come first screen on click of same
Home tab.

Thanks in advance.

@anup-geeky anup-geeky changed the title How to dispose third screen. How to call dispose method in third screen. Apr 30, 2020
@BilalShahid13
Copy link
Owner

BilalShahid13 commented Apr 30, 2020

The possible solution of the first problem will be to pass the PersistentTabController declared with the nav bar to the 3rd screen. You can do that by passing through arguments to successive screens or something like a provider. Then on the 3rd screen, add a listener to the controller in the initState or somewhere else. When index change is detected, call the dispose method.

Now for the second one, it is currently only possible by using a custom widget and defining your own tap function for an item. But this is an interesting feature which I'm hoping to add in a future update. Thanks for the suggestion!

@BilalShahid13
Copy link
Owner

The feature for popping to first screen on tapping an already selected tab is added in version 1.5.1. Please check it out.

Keep in mind that I'm using Flutter's default Navigator.canPop(context) to decided whether I can pop a screen or not. This does not work sometimes and I'm actively looking for the answer.

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

2 participants