From fd2b1bc720ea35f49fd79a32264ded245c4aa03c Mon Sep 17 00:00:00 2001 From: Ahmed Mohamed Sameh Date: Fri, 17 Oct 2025 01:07:52 +0300 Subject: [PATCH] Make sure that a NavigationRail doesn't crash in 0x0 environment (#177022) This is my attempt to handle https://github.com/flutter/flutter/issues/6537 for the NavigationRail widget. --- .../test/material/navigation_rail_test.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/flutter/test/material/navigation_rail_test.dart b/packages/flutter/test/material/navigation_rail_test.dart index faf488b5633..5df95b2f458 100644 --- a/packages/flutter/test/material/navigation_rail_test.dart +++ b/packages/flutter/test/material/navigation_rail_test.dart @@ -6127,6 +6127,24 @@ void main() { expect(updatedWidthRTL, defaultWidth + safeAreaPadding); }); }); // End Material 2 group + + testWidgets('NavigationRail does not crash at zero area', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: Center( + child: SizedBox.shrink( + child: NavigationRail( + destinations: const [ + NavigationRailDestination(icon: Icon(Icons.abc), label: Text('X')), + ], + selectedIndex: 0, + ), + ), + ), + ), + ); + expect(tester.getSize(find.byType(NavigationRail)), Size.zero); + }); } TestSemantics _expectedSemantics({bool scrollable = false}) {