Flutter UI Widgets

Nov 9 2021 · Dart 2.14, Flutter 2.5, VS Code 1.61

Part 1: Flutter UI Widgets

06. Work with BottomNavigationBar

Episode complete

Play next episode

About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 05. Create Scrollable Contents Next episode: 07. Use the FutureBuilder Widget

Notes: 06. Work with BottomNavigationBar

If you’re using Flutter 1.17 and above then you won’t get the Dart constraint error since those versions work a newer Dart sdk.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

Tabs are very common is most modern apps and Flutter provides us with different tab based widgets. The Scaffold widget provides us with the BottomNavigationBar which let’s us add a widget that can be shown at the bottom of the screen. Let’s add a BottomNavigationBar widget. Paste the following code inside the Scaffold:

bottomNavigationBar: BottomNavigationBar(
  currentIndex: 0,
  onTap: (int index) {},
  items: [
    const BottomNavigationBarItem(
      label: 'Home',
      icon: Icon(Icons.home),
    const BottomNavigationBarItem(
      label: 'Inbox',
      icon: Icon(Icons.mail),
// Members
final List<Widget> _pages = [
  const HomePage(),
  const InboxPage(),

int _selectedIndex = 0;

// Scaffold
body: IndexedStack(
  index: _selectedIndex,
  children: <Widget>[..._pages],

// BottomNavigationBar
currentIndex: _selectedIndex,
_onTapped(int index) {
  setState(() {
    _selectedIndex = index;
onTap: _onTapped,