From da19a88ca22711ff86474d141a1be7de4015f17c Mon Sep 17 00:00:00 2001 From: xubaolin Date: Wed, 8 Jun 2022 04:53:07 +0800 Subject: [PATCH] Improve the `SliverChildBuilderDelegate` docs for folk to troubleshoot. (#103183) --- packages/flutter/lib/src/widgets/sliver.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/flutter/lib/src/widgets/sliver.dart b/packages/flutter/lib/src/widgets/sliver.dart index 2d4579aee6..306c7fb3ee 100644 --- a/packages/flutter/lib/src/widgets/sliver.dart +++ b/packages/flutter/lib/src/widgets/sliver.dart @@ -375,6 +375,11 @@ class SliverChildBuilderDelegate extends SliverChildDelegate { /// Should return null if asked to build a widget with a greater index than /// exists. /// + /// May result in an infinite loop or run out of memory if [childCount] is null + /// and the [builder] always provides a zero-size widget (such as `Container()` + /// or `SizedBox.shrink()`). If possible, provide children with non-zero size, + /// return null from [builder], or set a [childCount]. + /// /// The delegate wraps the children returned by this builder in /// [RepaintBoundary] widgets. final NullableIndexedWidgetBuilder builder; @@ -383,6 +388,11 @@ class SliverChildBuilderDelegate extends SliverChildDelegate { /// /// If null, the number of children is determined by the least index for which /// [builder] returns null. + /// + /// May result in an infinite loop or run out of memory if [childCount] is null + /// and the [builder] always provides a zero-size widget (such as `Container()` + /// or `SizedBox.shrink()`). If possible, provide children with non-zero size, + /// return null from [builder], or set a [childCount]. final int? childCount; /// Whether to wrap each child in an [AutomaticKeepAlive].