From d85497d91bcc87ca8ed5e6e6ce7a77bb67986ff6 Mon Sep 17 00:00:00 2001 From: Qun Cheng <36861262+QuncCccccc@users.noreply.github.com> Date: Wed, 7 Feb 2024 23:14:56 +0000 Subject: [PATCH] Add a unit test for `NavigationRail` (#143108) Adding `SingleChildScrollView` to `NavigationRail` may cause exception if the nav rail has some expanded widgets inside, like the issue: https://github.com/flutter/flutter/issues/143061. This PR is just to add a unit test to avoid causing this breaking again. --- .../test/material/navigation_rail_test.dart | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/flutter/test/material/navigation_rail_test.dart b/packages/flutter/test/material/navigation_rail_test.dart index 7085dec5de..dd4e2cab29 100644 --- a/packages/flutter/test/material/navigation_rail_test.dart +++ b/packages/flutter/test/material/navigation_rail_test.dart @@ -3605,6 +3605,32 @@ void main() { expect(inkFeatures, paints..circle(color: Colors.transparent)); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933 + testWidgets('Navigation rail can have expanded widgets inside', (WidgetTester tester) async { + await _pumpNavigationRail( + tester, + navigationRail: NavigationRail( + selectedIndex: 0, + destinations: const [ + NavigationRailDestination( + icon: Icon(Icons.favorite_border), + label: Text('Abc'), + ), + NavigationRailDestination( + icon: Icon(Icons.bookmark_border), + label: Text('Bcd'), + ), + ], + trailing: const Expanded( + child: Icon(Icons.search), + ), + ), + ); + + await tester.pumpAndSettle(); + + expect(tester.takeException(), isNull); + }); + group('Material 2', () { // These tests are only relevant for Material 2. Once Material 2 // support is deprecated and the APIs are removed, these tests