Home > Net >  How to solve ElevatedButton error in flutter
How to solve ElevatedButton error in flutter

Time:03-21

I am new to flutter and I am developing an app in Flutter. While I am doing this, I try to add ElevatedButton which is the latest version of RaisedButton, and its return error and I am also not sure why. I will insert the error code image and would be grateful if someone tells me what is the reason for the error and how to solve it. Thank you

enter image description here

CodePudding user response:

You need to add a child widget (it is required in addition to onPressed function). Here is a sample code for Elevated Button. You can adjust it based on your needs:

ElevatedButton(
    style: ElevatedButton.styleFrom(
        onPrimary: Colors.white,
        primary: Color(0xffccbbd7),
        minimumSize: const Size(330,70),
        shape: const RoundedRectangleBorder(
            borderRadius: BorderRadius.all(
               Radius.circular(5),
            ),
        ),
    ),
    onPressed: () {},
    child: const Text('click'),
),

CodePudding user response:

You Forgot the child Widget inside ElevatedButton, in this button onPressed and child widgets are required

Refer image

  • Related