@@ -1154,6 +1154,67 @@ void main() {
11541154 );
11551155 });
11561156
1157+ group ('rebuilds with a different number of children' , () {
1158+ testWidgets (
1159+ 'does not throw a RangeError when child count shrinks' ,
1160+ (WidgetTester tester) async {
1161+ final threeChildSplit = buildSplitPane (
1162+ Axis .horizontal,
1163+ children: const [_w1, _w2, _w3],
1164+ initialFractions: const [0.2 , 0.4 , 0.4 ],
1165+ minSizes: const [50.0 , 50.0 , 50.0 ],
1166+ );
1167+ await tester.pumpWidget (wrap (threeChildSplit));
1168+ expect (find.byKey (_k1), findsOneWidget);
1169+ expect (find.byKey (_k2), findsOneWidget);
1170+ expect (find.byKey (_k3), findsOneWidget);
1171+
1172+ final twoChildSplit = buildSplitPane (
1173+ Axis .horizontal,
1174+ children: const [_w1, _w2],
1175+ initialFractions: const [0.5 , 0.5 ],
1176+ minSizes: const [50.0 , 50.0 ],
1177+ );
1178+ await tester.pumpWidget (wrap (twoChildSplit));
1179+ await tester.pumpAndSettle ();
1180+
1181+ expect (tester.takeException (), isNull);
1182+ expect (find.byKey (_k1), findsOneWidget);
1183+ expect (find.byKey (_k2), findsOneWidget);
1184+ expect (find.byKey (_k3), findsNothing);
1185+ },
1186+ );
1187+
1188+ testWidgets (
1189+ 'does not throw a RangeError when child count grows' ,
1190+ (WidgetTester tester) async {
1191+ final twoChildSplit = buildSplitPane (
1192+ Axis .horizontal,
1193+ children: const [_w1, _w2],
1194+ initialFractions: const [0.5 , 0.5 ],
1195+ minSizes: const [50.0 , 50.0 ],
1196+ );
1197+ await tester.pumpWidget (wrap (twoChildSplit));
1198+ expect (find.byKey (_k1), findsOneWidget);
1199+ expect (find.byKey (_k2), findsOneWidget);
1200+
1201+ final threeChildSplit = buildSplitPane (
1202+ Axis .horizontal,
1203+ children: const [_w1, _w2, _w3],
1204+ initialFractions: const [0.2 , 0.4 , 0.4 ],
1205+ minSizes: const [50.0 , 50.0 , 50.0 ],
1206+ );
1207+ await tester.pumpWidget (wrap (threeChildSplit));
1208+ await tester.pumpAndSettle ();
1209+
1210+ expect (tester.takeException (), isNull);
1211+ expect (find.byKey (_k1), findsOneWidget);
1212+ expect (find.byKey (_k2), findsOneWidget);
1213+ expect (find.byKey (_k3), findsOneWidget);
1214+ },
1215+ );
1216+ });
1217+
11571218 group ('axisFor' , () {
11581219 testWidgetsWithWindowSize (
11591220 'return Axis.horizontal' ,
0 commit comments