Search code examples
androidflutterflutter-bottomnavigation

Exception caught by widgets library error in Flutter


Source file with incoming error

Bottom Navigation Bar Code


Solution

  • In your BottomNavigationBar there's an items property:

    Scaffold(
            bottomNavigationBar: BottomNavigationBar(items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
        ]));
    

    this property accepts a List<BottomNavigationBarItem>. Now, the length of this list should be at least 2.

    For example:

    Scaffold(
          bottomNavigationBar: BottomNavigationBar(items: [
            BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
            BottomNavigationBarItem(icon: Icon(Icons.search), label: 'search'),
          ]),
        );
    

    but your providing only one BottomNavigationBarItem, so make sure you have at least one more BottomNavigationBarItem