* Added sample code for BottomNavigationBar widget [#21136] * bottomnavigationbaritems made single line
This commit is contained in:
parent
cef11417da
commit
a0010d391c
@ -68,6 +68,61 @@ enum BottomNavigationBarType {
|
|||||||
/// case it's assumed that each item will have a different background color
|
/// case it's assumed that each item will have a different background color
|
||||||
/// and that background color will contrast well with white.
|
/// and that background color will contrast well with white.
|
||||||
///
|
///
|
||||||
|
/// ## Sample Code
|
||||||
|
///
|
||||||
|
/// This example shows a [BottomNavigationBar] as it is used within a [Scaffold]
|
||||||
|
/// widget. The [BottomNavigationBar] has three [BottomNavigationBarItem]
|
||||||
|
/// widgets and the [currentIndex] is set to index 1. The color of the selected
|
||||||
|
/// item is set to a purple color. A function is called whenever any item is
|
||||||
|
/// tapped and the function helps display the appropriate [Text] in the body of
|
||||||
|
/// the [Scaffold].
|
||||||
|
///
|
||||||
|
/// ```dart
|
||||||
|
/// class MyHomePage extends StatefulWidget {
|
||||||
|
/// MyHomePage({Key key}) : super(key: key);
|
||||||
|
///
|
||||||
|
/// @override
|
||||||
|
/// _MyHomePageState createState() => _MyHomePageState();
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// class _MyHomePageState extends State<MyHomePage> {
|
||||||
|
/// int _selectedIndex = 1;
|
||||||
|
/// final _widgetOptions = [
|
||||||
|
/// Text('Index 0: Home'),
|
||||||
|
/// Text('Index 1: Business'),
|
||||||
|
/// Text('Index 2: School'),
|
||||||
|
/// ];
|
||||||
|
///
|
||||||
|
/// @override
|
||||||
|
/// Widget build(BuildContext context) {
|
||||||
|
/// return Scaffold(
|
||||||
|
/// appBar: AppBar(
|
||||||
|
/// title: Text('BottomNavigationBar Sample'),
|
||||||
|
/// ),
|
||||||
|
/// body: Center(
|
||||||
|
/// child: _widgetOptions.elementAt(_selectedIndex),
|
||||||
|
/// ),
|
||||||
|
/// bottomNavigationBar: BottomNavigationBar(
|
||||||
|
/// items: <BottomNavigationBarItem>[
|
||||||
|
/// BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('Home')),
|
||||||
|
/// BottomNavigationBarItem(icon: Icon(Icons.business), title: Text('Business')),
|
||||||
|
/// BottomNavigationBarItem(icon: Icon(Icons.school), title: Text('School')),
|
||||||
|
/// ],
|
||||||
|
/// currentIndex: _selectedIndex,
|
||||||
|
/// fixedColor: Colors.deepPurple,
|
||||||
|
/// onTap: _onItemTapped,
|
||||||
|
/// ),
|
||||||
|
/// );
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// void _onItemTapped(int index) {
|
||||||
|
/// setState(() {
|
||||||
|
/// _selectedIndex = index;
|
||||||
|
/// });
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [BottomNavigationBarItem]
|
/// * [BottomNavigationBarItem]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user