Commit 7498ad00 authored by Efthymis Sarmpanis's avatar Efthymis Sarmpanis Committed by Kate Lovett

Add a more meaningful message to the assertion on children property of...

Add a more meaningful message to the assertion on children property of MultiChildRenderObjectWidget and SliverChildListDelegate. (#32487)
parent d9f6cada
......@@ -1663,7 +1663,15 @@ abstract class MultiChildRenderObjectWidget extends RenderObjectWidget {
/// objects.
MultiChildRenderObjectWidget({ Key key, this.children = const <Widget>[] })
: 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.
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment