-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[WIP] Fix tab crash when index changes before layout #152947
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
Conversation
| // Dispose if we had one already, this can happen if the index of the tab | ||
| // controller, which sets _currentIndex, changes before we have laid out. | ||
| _pageController?.dispose(); | ||
| _pageController = PageController( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing this, can _pageController somehow sets its _PagePosition's _pageToUseOnStartup if the viewport dimension is not yet applied?
| if (_controller!.index != _currentIndex) { | ||
| _currentIndex = _controller!.index; | ||
| _warpToCurrentIndex(); | ||
| if (_pageCanChange()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happen if this is false? do we just drop the change?
…s are set (#153017) ## Description This PR fixes `PageController` throwing when using `jumpToPage` or `animateToPage` to switch page before the viewport dimensions were retrieved. Solution based on #152947 (comment). ## Related Issue Fixes #86222. Fixes #152079 ## Tests Adds 2 tests.
…s are set (flutter#153017) ## Description This PR fixes `PageController` throwing when using `jumpToPage` or `animateToPage` to switch page before the viewport dimensions were retrieved. Solution based on flutter#152947 (comment). ## Related Issue Fixes flutter#86222. Fixes flutter#152079 ## Tests Adds 2 tests.
…s are set (flutter#153017) ## Description This PR fixes `PageController` throwing when using `jumpToPage` or `animateToPage` to switch page before the viewport dimensions were retrieved. Solution based on flutter#152947 (comment). ## Related Issue Fixes flutter#86222. Fixes flutter#152079 ## Tests Adds 2 tests.
…s are set (flutter#153017) ## Description This PR fixes `PageController` throwing when using `jumpToPage` or `animateToPage` to switch page before the viewport dimensions were retrieved. Solution based on flutter#152947 (comment). ## Related Issue Fixes flutter#86222. Fixes flutter#152079 ## Tests Adds 2 tests.
WIP - I am not sure this is the right fix, as I've worked on it it's grown in complexity.
This issue is urgent for an internal customer (b/357067239)
This crash can happen from multiple code paths, the customer issue does not have a repro, but I found two in the issue tracker:
TabBarViewcrashes when switching index before layout #86222I think these PRs are related, which is why the CC for @bleroux & @chunhtai - what do you two think here? I broke 3 tests here, not sure if this is the right way to go.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.