-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Do not crash if the controller and TabBarView are updated at different phases (build and layout) of the same frame. #104998
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
| } | ||
|
|
||
| bool _debugScheduleCheckHasValidTabsCount() { | ||
| WidgetsBinding.instance.addPostFrameCallback((Duration duration) { |
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.
if the TabBarView widget is in a LayoutBuilder and the DefaultTabBarController is not, build will be called twice in the same frame and the post frame callback will be scheduled twice.
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.
That would mean the error will be thrown twice if the length is indeed inconsistent at the end of the frame.
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.
Fixed.
|
LGTM modulo comments, as I don't know any other way to get around this. I had a pull request that tries to prevent widgets inside of a LayoutBuilder from being rebuilt twice but I stopped working on that because of lack of interest. Do you mind if I repurpose #104994 for double rebuild in layout builder? If we can fix that we'll be able to remove the post frame checks back to the build method. |
I'm curious how we can identify widgets under a LayoutBuilder elegant. Even if we do, we also need to ensure that multiple builds during a frame cannot throw. Because in the lazy loaded sliver, the build will also happen in the layout phase. |
|
For slivers we're only adding/removing children on demand so there doesn't appear to be a double build problem. For |
…different phases (build and layout) of the same frame. (flutter/flutter#104998)
…different phases (build and layout) of the same frame. (flutter/flutter#104998)
…different phases (build and layout) of the same frame. (flutter/flutter#104998)
…different phases (build and layout) of the same frame. (flutter/flutter#104998)
…different phases (build and layout) of the same frame. (flutter/flutter#104998)
…different phases (build and layout) of the same frame. (flutter/flutter#104998)
…different phases (build and layout) of the same frame. (flutter/flutter#104998)
…different phases (build and layout) of the same frame. (flutter/flutter#104998)
…t phases (build and layout) of the same frame. (flutter#104998)
…different phases (build and layout) of the same frame. (flutter/flutter#104998)
…different phases (build and layout) of the same frame. (flutter/flutter#104998)
Fixes #104994
If wrap the
TabBarViewor 'TabBar' under aLayoutBuilderbut let theDefaultTabControllerout of theLayoutBuilder, it may be thrown.This is because the
TabBarViewor 'TabBar' will be updated later in the layout phase.So I just move the checker to the post-frame phase.
This also blocks #104958 landing.