Search code examples
flutterdarterror-handlingdart-null-safety

The named parameter 'title' isn't defined.\nTry correcting the name to an existing named parame with the name 'title'.",


my fried is making a traveller app then we face this error in every title line(The named parameter 'title' isn't defined.\nTry correcting the name to an existing named parameter's name, or defining a named parameter with the name 'title'.",)

  title: SizedBox.shrink(),//The named parameter 'title' isn't defined.\nTry correcting the name to an existing named parameter's name, or defining a named parameter with the name 'title'.",
              ),
              BottomNavigationBarItem(
                icon: Icon(
                  Icons.local_pizza,
                  size: 30.0,
                ),
                title: SizedBox.shrink(),//The named parameter 'title' isn't defined.\nTry correcting the name to an existing named parameter's name, or defining a named parameter with the name 'title'.",
              ),
              BottomNavigationBarItem(
                icon: CircleAvatar(
                  radius: 15.0,
                  backgroundImage: NetworkImage('http://i.imgur.com/zL4Krbz.jpg'),
                ),
                title: SizedBox.shrink(),//The named parameter 'title' isn't defined.\nTry correcting the name to an existing named parameter's name, or defining a named parameter with the name 'title'.",
          )
        ],

Solution

  • The BottomNavigationBarItem does not have a title field.

    It has a label field.

    You can check the documentation here.

    Also, since the label is of String? type, you cannot put a Widget there.

    BottomNavigationBarItem(
                    icon: Icon(
                      Icons.local_pizza,
                      size: 30.0,
                    ),
                    label: "Your label"
                  ),