Screenshot of what I am looking for
How can I achieve this side navigation bar (left) in Flutter? There is a widget for this if I'm not wrong, but I can't find the name anywhere.
The widget you are searching for is called NavigationRail.
It is very well documented as part of the official Flutter API.
The example usage is as follows:
int _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
children: <Widget>[
NavigationRail(
selectedIndex: _selectedIndex,
onDestinationSelected: (int index) {
setState(() {
_selectedIndex = index;
});
},
labelType: NavigationRailLabelType.selected,
destinations: [
NavigationRailDestination(
icon: Icon(Icons.favorite_border),
selectedIcon: Icon(Icons.favorite),
label: Text('First'),
),
NavigationRailDestination(
icon: Icon(Icons.bookmark_border),
selectedIcon: Icon(Icons.book),
label: Text('Second'),
),
NavigationRailDestination(
icon: Icon(Icons.star_border),
selectedIcon: Icon(Icons.star),
label: Text('Third'),
),
],
),
VerticalDivider(thickness: 1, width: 1),
// This is the main content.
Expanded(
child: Center(
child: Text('selectedIndex: $_selectedIndex'),
),
)
],
),
);
}
This is called Navigation Rail. You can find out more here
Usage:
child:NavigationRail(
selectedIndex:_currentIndex,
onDestinationSelected: (int index) {
setState(() {
// Change Index When Widget is Selected.
_currentIndex = index;
});
destinations:[
// You Navigation Rail Items/Destinations
NavigationRailDestination(
icon: Icon(Icons.favorite_border),
selectedIcon: Icon(Icons.favorite),
label: Text('Home'),
),
]
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With