skip to Main Content

So I’m trying to add a Column for another button for my Flutter app. But I keep getting an error for one of the parameters, bottomNavigationBar, and I don’t know why. All the error message says is that it isn’t defined. PS I’m using VS Code and MacOS for iOS simulator. I know this is an easy fix, but anyway here is the code.

I would copy/paste the code, but SOF has strict rules on code formatting. I formatted it on VSC, enter image description herethis website still wouldn’t accept it. But here is a screenshot of my code.

2

Answers


  1. Try closing the center widget which is started before Elevated Button. The problem with this code is that you are passing a child widget and bottom navigation bar to center widget. That might be giving the error.

    Login or Signup to reply.
  2. bottomNavigationBar is a parameter of the widget Scaffold. You’re missing a parenthesis ), your code should be like this:

    body: Center(
              child: ElevatedButton(
                onPressed: () {
                  setState(() {
                    buttonName = 'Login';
                  });
                },
                child: Text(buttonName),
              ),
            ), //Add parenthesis here
            bottomNavigationBar: BottomNavigationBar(
              items: const [],
            ),
    
    

    in order to work.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search