forked from firka/flutter
Migration guide for moving from BottomNavigationBar to NavigationBar (#128263)
Fixes https://github.com/flutter/flutter/issues/127213
This commit is contained in:
@@ -36,20 +36,22 @@ class _NavigationExampleState extends State<NavigationExample> {
|
||||
currentPageIndex = index;
|
||||
});
|
||||
},
|
||||
indicatorColor: Colors.amber[800],
|
||||
selectedIndex: currentPageIndex,
|
||||
destinations: const <Widget>[
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.explore),
|
||||
label: 'Explore',
|
||||
selectedIcon: Icon(Icons.home),
|
||||
icon: Icon(Icons.home_outlined),
|
||||
label: 'Home',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.commute),
|
||||
label: 'Commute',
|
||||
icon: Icon(Icons.business),
|
||||
label: 'Business',
|
||||
),
|
||||
NavigationDestination(
|
||||
selectedIcon: Icon(Icons.bookmark),
|
||||
icon: Icon(Icons.bookmark_border),
|
||||
label: 'Saved',
|
||||
selectedIcon: Icon(Icons.school),
|
||||
icon: Icon(Icons.school_outlined),
|
||||
label: 'School',
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -16,20 +16,20 @@ void main() {
|
||||
final NavigationBar navigationBarWidget = tester.firstWidget(find.byType(NavigationBar));
|
||||
|
||||
/// NavigationDestinations must be rendered
|
||||
expect(find.text('Explore'), findsOneWidget);
|
||||
expect(find.text('Commute'), findsOneWidget);
|
||||
expect(find.text('Saved'), findsOneWidget);
|
||||
expect(find.text('Home'), findsOneWidget);
|
||||
expect(find.text('Business'), findsOneWidget);
|
||||
expect(find.text('School'), findsOneWidget);
|
||||
|
||||
/// initial index must be zero
|
||||
expect(navigationBarWidget.selectedIndex, 0);
|
||||
|
||||
/// switch to second tab
|
||||
await tester.tap(find.text('Commute'));
|
||||
await tester.tap(find.text('Business'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Page 2'), findsOneWidget);
|
||||
|
||||
/// switch to third tab
|
||||
await tester.tap(find.text('Saved'));
|
||||
await tester.tap(find.text('School'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Page 3'), findsOneWidget);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user