Skip to content

Commit

Permalink
Added sample code for BottomNavigationBar widget [#21136] (#21615)
Browse files Browse the repository at this point in the history
* Added sample code for BottomNavigationBar widget [#21136]

* bottomnavigationbaritems made single line
  • Loading branch information
NPKompleet authored and Hixie committed Oct 16, 2018
1 parent cef1141 commit a0010d3
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions packages/flutter/lib/src/material/bottom_navigation_bar.dart
Expand Up @@ -68,6 +68,61 @@ enum BottomNavigationBarType {
/// case it's assumed that each item will have a different background color
/// 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:
///
/// * [BottomNavigationBarItem]
Expand Down

0 comments on commit a0010d3

Please sign in to comment.