Skip to content

Instantly share code, notes, and snippets.

@anmolseth06
Created May 10, 2020 18:49
Show Gist options
  • Select an option

  • Save anmolseth06/e71626ea5540857a1dd9e2e013b3149c to your computer and use it in GitHub Desktop.

Select an option

Save anmolseth06/e71626ea5540857a1dd9e2e013b3149c to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyStatefulWidget(),
);
}
}
class MyStatefulWidget extends StatefulWidget {
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
int _selectedIndex = 0;
List _childern = [
Container(
child: Text("HOME"),
color: Colors.cyan,
),
Container(
child: Text("FAVORITES"),
color: Colors.redAccent,
),
Container(
child: Text("BOOKMARK"),
color: Colors.greenAccent,
),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
children: <Widget>[
NavigationRail(
leading: Icon(Icons.home),
backgroundColor: Colors.cyan,
elevation: 2,
extended: true,
unselectedLabelTextStyle: GoogleFonts.lato(),
selectedLabelTextStyle: GoogleFonts.pacifico(),
selectedIndex: _selectedIndex,
onDestinationSelected: (index) {
setState(() {
_selectedIndex = index;
});
},
labelType: NavigationRailLabelType.selected,
destinations: [
NavigationRailDestination(
icon: Icon(Icons.home),
selectedIcon: Icon(Icons.home),
label: Text('Home'),
),
NavigationRailDestination(
icon: Icon(Icons.favorite),
selectedIcon: Icon(Icons.favorite_border),
label: Text('Home'),
),
NavigationRailDestination(
icon: Icon(Icons.bookmark),
selectedIcon: Icon(Icons.bookmark_border),
label: Text('Bookmark'),
),
],
),
Expanded(
child: _childern[_selectedIndex],
)
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment