-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Improve the SliverChildBuilderDelegate docs for folk to troubleshoot.
#103183
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
|
flutter/packages/flutter/lib/src/rendering/sliver_list.dart Lines 279 to 285 in 704bb36
RenderSliverList.performLayout() will create many children to fill up the viewport, so zero-size children may cause an infinite loop.This is hard to catch at runtime, so only be explained through documentation. |
SliverChildBuilderDelegate docs for folk to troubleshot.SliverChildBuilderDelegate docs for folk to troubleshoot.
Piinks
left a comment
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.
Hey @xu-baolin! Always good to see you. :)
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.
Is there a way we can catch this and throw an error?
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.
I've tried both solutions, but neither is perfect.
- Timeout check. When an exception is thrown if time out(about 3 seconds), the Flutter error thread will take about ten seconds(or more) to collect error information (because thousands of children have been created at this time), and the final error message printed to the console will overflow, and the user cannot well informed of what happened;
- When 100 children of zero size are created continuously, throw an exception, which is a bit hacky and maybe misjudged.
Wondering if you have any suggestions?
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.
Hmm.. you are right, this is very difficult to catch accurately.
We cannot add timeouts (https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#never-check-if-a-port-is-available-before-using-it-never-add-timeouts-and-other-race-conditions), and it is possible the user could have zero sized children in the thousands preceding a child that actually has a size.
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.
Perhaps we can word it a bit differently, right now it sounds like a warning against this scenario. What should the user do then if they run into this?
Set a child count, return null from builder, or provide children with a size sound like options, what do you think?
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.
| /// and the [builder] always provide a zero-size widget, such as `Container()` | |
| /// and the [builder] always provides a zero-size widget, such as `Container()` |
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.
Hmm.. you are right, this is very difficult to catch accurately.
We cannot add timeouts (https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#never-check-if-a-port-is-available-before-using-it-never-add-timeouts-and-other-race-conditions), and it is possible the user could have zero sized children in the thousands preceding a child that actually has a size.
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.
| /// [builder] always provide a zero size widget, such as `Container()` | |
| /// [builder] always provides a zero size widget, such as `Container()` |
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.
Perhaps we can word it a bit differently, right now it sounds like a warning against this scenario. What should the user do then if they run into this?
Set a child count, return null from builder, or provide children with a size sound like options, what do you think?
|
@xu-baolin Do you still have plans to follow up on the feedback given above? |
|
I will be back soon! |
Piinks
left a comment
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.

Improve some docs for folk to troubleshoot.
Fixes #102904