Skip to content

Commit d85497d

Browse files
authored
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: flutter/flutter#143061. This PR is just to add a unit test to avoid causing this breaking again.
1 parent 52f897b commit d85497d

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

packages/flutter/test/material/navigation_rail_test.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,6 +3605,32 @@ void main() {
36053605
expect(inkFeatures, paints..circle(color: Colors.transparent));
36063606
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
36073607

3608+
testWidgets('Navigation rail can have expanded widgets inside', (WidgetTester tester) async {
3609+
await _pumpNavigationRail(
3610+
tester,
3611+
navigationRail: NavigationRail(
3612+
selectedIndex: 0,
3613+
destinations: const <NavigationRailDestination>[
3614+
NavigationRailDestination(
3615+
icon: Icon(Icons.favorite_border),
3616+
label: Text('Abc'),
3617+
),
3618+
NavigationRailDestination(
3619+
icon: Icon(Icons.bookmark_border),
3620+
label: Text('Bcd'),
3621+
),
3622+
],
3623+
trailing: const Expanded(
3624+
child: Icon(Icons.search),
3625+
),
3626+
),
3627+
);
3628+
3629+
await tester.pumpAndSettle();
3630+
3631+
expect(tester.takeException(), isNull);
3632+
});
3633+
36083634
group('Material 2', () {
36093635
// These tests are only relevant for Material 2. Once Material 2
36103636
// support is deprecated and the APIs are removed, these tests

0 commit comments

Comments
 (0)