Bottom navigation bar
A bottom navigation bar keeps the main destinations of an app within reach. Keep their labels and positions stable as people move between screens.
Switch destinations
#Choose Search and then Home. The page content changes with the selected destination.
components/navigation-bar/appliance/switch_destination.dart
import 'package:flutter/widgets.dart';
import 'package:material_ui/material_ui.dart' show Icons;
import 'package:appliance_ui/appliance_ui.dart';
class SwitchDestination extends StatefulWidget {
const SwitchDestination({super.key});
@override
State<SwitchDestination> createState() => _SwitchDestinationState();
}
class _SwitchDestinationState extends State<SwitchDestination> {
int selected = 0;
static const destinations = [
ApplianceDestination(icon: Icons.home_outlined, label: 'Home'),
ApplianceDestination(icon: Icons.search, label: 'Search'),
];
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(selected == 0 ? 'Home page' : 'Search page'),
const SizedBox(height: 12),
ApplianceNavigationBar(
destinations: destinations,
selectedIndex: selected,
onSelected: (next) => setState(() => selected = next),
),
],
);
}
Parameters
ApplianceNavigationBar API ↗destinations- The destinations in reading order.
selectedIndex- Zero-based index of the visible page.
onSelected- Receives the index of the chosen destination.
Shared behaviour
- Keyboard and focus. Follow the focus indicator through the destinations. Most bars accept Tab or the arrows to reach Search and Enter to choose it.
- Screen readers. Read both destination names and inspect the selected state. The content identifies the page that opened.
- Direction and type. Compare destination order in RTL. At 200% text, check the labels beneath or beside the icons.