|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be
|
3 | 3 | // found in the LICENSE file.
|
4 | 4 |
|
| 5 | +import 'package:flutter/foundation.dart'; |
5 | 6 | import 'package:flutter/rendering.dart';
|
6 | 7 | import 'package:flutter_test/flutter_test.dart';
|
7 | 8 |
|
@@ -118,6 +119,33 @@ void main() {
|
118 | 119 | expect(visitedChildren.first, child2);
|
119 | 120 | });
|
120 | 121 |
|
| 122 | + test('debugDescribeChildren marks invisible children as offstage', () { |
| 123 | + final RenderBox child1 = RenderConstrainedBox( |
| 124 | + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)), |
| 125 | + ); |
| 126 | + final RenderBox child2 = RenderConstrainedBox( |
| 127 | + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)), |
| 128 | + ); |
| 129 | + final RenderBox child3 = RenderConstrainedBox( |
| 130 | + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)), |
| 131 | + ); |
| 132 | + |
| 133 | + final RenderBox stack = RenderIndexedStack( |
| 134 | + index: 2, |
| 135 | + children: <RenderBox>[child1, child2, child3], |
| 136 | + ); |
| 137 | + |
| 138 | + final List<DiagnosticsNode> diagnosticNodes = stack.debugDescribeChildren(); |
| 139 | + |
| 140 | + expect(diagnosticNodes[0].name, 'child 1'); |
| 141 | + expect(diagnosticNodes[0].style, DiagnosticsTreeStyle.offstage); |
| 142 | + |
| 143 | + expect(diagnosticNodes[1].name, 'child 2'); |
| 144 | + expect(diagnosticNodes[1].style, DiagnosticsTreeStyle.offstage); |
| 145 | + |
| 146 | + expect(diagnosticNodes[2].name, 'child 3'); |
| 147 | + expect(diagnosticNodes[2].style, DiagnosticsTreeStyle.sparse); |
| 148 | + }); |
121 | 149 | });
|
122 | 150 |
|
123 | 151 | // More tests in ../widgets/stack_test.dart
|
|
0 commit comments