|
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], |
|
) |
|
], |
|
), |
|
); |
|
} |
|
} |