Fix Exception on Nested TabBarView disposal#31581
Merged
shihaohong merged 14 commits intoflutter:masterfrom May 4, 2019
shihaohong:nested-tabbars
Merged
Fix Exception on Nested TabBarView disposal#31581shihaohong merged 14 commits intoflutter:masterfrom shihaohong:nested-tabbars
shihaohong merged 14 commits intoflutter:masterfrom
shihaohong:nested-tabbars
Conversation
Contributor
|
#31978 merged |
HansMuller
approved these changes
May 4, 2019
chunhtai
reviewed
May 4, 2019
|
|
||
| @override | ||
| void dispose() { | ||
| // Sets `pixels` to a non-null value before `ScrollPosition.dispose` is |
Contributor
There was a problem hiding this comment.
can you add a TODO and link to the issue and note once the issue is fix we can remove this workaround
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a TabBarView is nested in a page of another TabBarView, there will be particular scenarios that will throw an exception.
To reproduce this issue, two conditions must be true:
(ie. current index = 0, tap on tab at index 3 when tab at index 2 has nested TabBarView)
This happens when the framework tries to build
_PagePosition, then dispose of it beforeapplyViewportDimensionhas the chance to be called to setpixelsto a non-null value based on the size of the viewport. This fix adds a flag to determine ifapplyViewportDimensionis invoked beforedispose. If it hasn't been, thendisposewill setpixelsto an arbitrary value before attempting to dispose of it.First exception: This is due to the introduction of #29188, which happens because the initial swap that is necessary for warping causes the nested page that is swapped but not shown to be disposed of before
applyViewportDimensionto be called.Second exception: This one is caused by the animation of the page during warp. The last frame does not build before the second
setStateis called to swap the children back to their original positions, causing the nested page to be built and disposed of beforeapplyViewportDimensioncan be called.TODO:
TabBarViewbuilds its last frame beforesetStateis called to re-swap the children back to their original locations. ScrollPosition.animateTo should build last frame before resolving animation #32054Related Issues
Fixes #18756
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?