Skip to content

Commit da19a88

Browse files
authored
Improve the SliverChildBuilderDelegate docs for folk to troubleshoot. (#103183)
1 parent 48d04b5 commit da19a88

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/flutter/lib/src/widgets/sliver.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ class SliverChildBuilderDelegate extends SliverChildDelegate {
375375
/// Should return null if asked to build a widget with a greater index than
376376
/// exists.
377377
///
378+
/// May result in an infinite loop or run out of memory if [childCount] is null
379+
/// and the [builder] always provides a zero-size widget (such as `Container()`
380+
/// or `SizedBox.shrink()`). If possible, provide children with non-zero size,
381+
/// return null from [builder], or set a [childCount].
382+
///
378383
/// The delegate wraps the children returned by this builder in
379384
/// [RepaintBoundary] widgets.
380385
final NullableIndexedWidgetBuilder builder;
@@ -383,6 +388,11 @@ class SliverChildBuilderDelegate extends SliverChildDelegate {
383388
///
384389
/// If null, the number of children is determined by the least index for which
385390
/// [builder] returns null.
391+
///
392+
/// May result in an infinite loop or run out of memory if [childCount] is null
393+
/// and the [builder] always provides a zero-size widget (such as `Container()`
394+
/// or `SizedBox.shrink()`). If possible, provide children with non-zero size,
395+
/// return null from [builder], or set a [childCount].
386396
final int? childCount;
387397

388398
/// Whether to wrap each child in an [AutomaticKeepAlive].

0 commit comments

Comments
 (0)