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.
This commit is contained in:
Qun Cheng 2024-02-07 23:14:56 +00:00 committed by GitHub
parent 52f897be5f
commit d85497d91b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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>[
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