Unverified Commit b26346f2 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

fix null safe check in RenderIndexedStack (#107581)

parent d949ca42
......@@ -790,7 +790,7 @@ class RenderIndexedStack extends RenderStack {
while (child != null) {
children.add(child.toDiagnosticsNode(
name: 'child ${i + 1}',
style: i != index! ? DiagnosticsTreeStyle.offstage : null,
style: i != index ? DiagnosticsTreeStyle.offstage : null,
));
child = (child.parentData! as StackParentData).nextSibling;
i += 1;
......
......@@ -145,6 +145,34 @@ void main() {
expect(diagnosticNodes[2].name, 'child 3');
expect(diagnosticNodes[2].style, DiagnosticsTreeStyle.sparse);
});
test('debugDescribeChildren handles a null index', () {
final RenderBox child1 = RenderConstrainedBox(
additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)),
);
final RenderBox child2 = RenderConstrainedBox(
additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)),
);
final RenderBox child3 = RenderConstrainedBox(
additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)),
);
final RenderBox stack = RenderIndexedStack(
index: null,
children: <RenderBox>[child1, child2, child3],
);
final List<DiagnosticsNode> diagnosticNodes = stack.debugDescribeChildren();
expect(diagnosticNodes[0].name, 'child 1');
expect(diagnosticNodes[0].style, DiagnosticsTreeStyle.offstage);
expect(diagnosticNodes[1].name, 'child 2');
expect(diagnosticNodes[1].style, DiagnosticsTreeStyle.offstage);
expect(diagnosticNodes[2].name, 'child 3');
expect(diagnosticNodes[2].style, DiagnosticsTreeStyle.offstage);
});
});
test('Stack in Flex can layout with no children', () {
......
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