I tried to add color to my FlatButton in Flutter but I get an error as below: The named parameter 'color' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name
I tried to add color to my FlatButton in Flutter but I get an error as below: The named parameter 'color' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name
You want to use FlatButton but you are calling FloatingActionButton. that is your first issue.
You can use backgroundColor to change the background color of FloatingActionButton, like this:
FloatingActionButton(
onPressed: () {},
backgroundColor: Colors.red,
child: Text('click'),
),
But I notice that you mention FlatButton in your description. FlatButton is deprecated and shouldn't be used, instead use TextButton, like this:
TextButton(
onPressed: () {},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.red)),
child: Text('click'),
),