Home > OS >  I'm getting a strange error when using "color:"
I'm getting a strange error when using "color:"

Time:09-24

I get this error when using color:

The named parameter 'color' isn't defined.

code is:

body: Center(
  child: ElevatedButton(
    child: Text('click'),
    onPressed: () {}  ,
    color: Colors.green[300],
  ),
),

CodePudding user response:

Type style then next is this

  ElevatedButton(
   style: ElevatedButton.styleFrom(
     primary: Colors.green[300],
        ),
      onPressed: () {},
      child: Text("click"),
   ),
  • Related