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

The bottom menu bar of the pageView returns to the internal page and then toggles the TAB exception #59

Closed
948911908 opened this issue Apr 28, 2020 · 3 comments
Assignees

Comments

@948911908
Copy link

Describe the bug
When I use the pageView to switch to the bottom menu, initState of the current page will be triggered again when I enter the "from" page on one TAB and then return to the "from" page and cut to another TAB. But I have to do all TAB page is "AutomaticKeepAliveClientMixin" processing.

**To Reproduce**
Steps to reproduce the behavior:
image

Expected behavior
I want to switch from the TAB page to another TAB page without triggering "initState" repeatedly.

Flutter Version:
1.12.13+hotfix.9

Get Version:
^1.11.1

Describe on which device you found the bug:
all

Minimal reproduce code
Provide a minimum reproduction code for the problem

@jonataslaw
Copy link
Owner

jonataslaw commented Apr 28, 2020

Sorry, none of this has anything to do with this lib.
If you are unsure of how to use Flutter, open an issue in Flutter or StackOverflow.
If you have any questions regarding Get, do not hesitate to open another issue.

@jonataslaw
Copy link
Owner

And just to help you, your problem is in:
children: _pages

You should never return a function in a widget or list of widgets.
Create a StatefulWidget for each page, use const in the constructs of each one, and call them const inside of children:, and it will not be rebuilt again with setState.

I know that in many languages (like javascript) you can do this, and in dart it works, but it is bad practice and causes side effects, like rebuilding every setState, as mentioned

@948911908
Copy link
Author

@jonataslaw Ok, thank you for your 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