diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 9ae2d5a64b..fa6da5abdc 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -1663,7 +1663,15 @@ abstract class MultiChildRenderObjectWidget extends RenderObjectWidget { /// objects. MultiChildRenderObjectWidget({ Key key, this.children = const [] }) : assert(children != null), - assert(!children.any((Widget child) => child == null)), // https://github.com/dart-lang/sdk/issues/29276 + assert(() { + final int index = children.indexOf(null); + if (index >= 0) { + throw AssertionError( + "The widget's children must not contain any null values, but a null value was found at index $index" + ); + } + return true; + }()), // https://github.com/dart-lang/sdk/issues/29276 super(key: key); /// The widgets below this widget in the tree. diff --git a/packages/flutter/lib/src/widgets/sliver.dart b/packages/flutter/lib/src/widgets/sliver.dart index aa6f7e5f9a..53a28a64e2 100644 --- a/packages/flutter/lib/src/widgets/sliver.dart +++ b/packages/flutter/lib/src/widgets/sliver.dart @@ -670,7 +670,10 @@ class SliverChildListDelegate extends SliverChildDelegate { return null; Widget child = children[index]; final Key key = child.key != null? _SaltedValueKey(child.key) : null; - assert(child != null); + assert( + child != null, + "The sliver's children must not contain null values, but a null value was found at index $index" + ); if (addRepaintBoundaries) child = RepaintBoundary(child: child); if (addSemanticIndexes) {