Answers for "flutter button background color"

4

textbutton background color flutter

// first way (most upvoted)
TextButton(
    child: Text('test'),
    style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.red)),
    onPressed: () {},
),

// second way 
TextButton(
  child: Text('Example'),
  onPressed: () {},
  style: TextButton.styleFrom(backgroundcolor: Colors.red),
)

// third way
TextButton(
  onPressed: () {},
  child: Container(
    padding: EdgeInsets.fromLTRB(30, 10, 30, 10),
    color: Colors.red,
    child: Text(""),
  ),
)
Posted by: Guest on June-15-2021
1

raised button background color doesn't changeflutter

RaisedButton(
              onPressed: null,
              child: Text('Get in'), // change it to sign-in
              color: Colors.blue,
              disabledColor: Colors.blue,//add this to your code
            )
Posted by: Guest on October-19-2020
1

How to change background color of Elevated Button in flutter

ElevatedButton(
              style: ElevatedButton.styleFrom(
                primary: Colors.amber,
              ), 
              child: Text('ElevatedButton'),
              onPressed: () {},
            ),
Posted by: Guest on August-24-2021
0

add background color to button flutte

bool isButtonPressed = false;

RaisedButton(
            color: isButtonPressed ? Colors.green : Colors.red,
            onPressed: () {
              setState(() {
                isButtonPressed =!isButtonPressed;
              });
            },
          ),
Posted by: Guest on February-04-2021
2

raisedbutton background color

List<bool> _list = [true, false, true, false];

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(title: Text("Title")),
    body: ListView(children: _buildButtons()),
  );
}

List<Widget> _buildButtons() {
  List<Widget> listButtons = List.generate(_list.length, (i) {
    return RaisedButton(
      color: _list[i] ? Colors.green : Colors.red,
      onPressed: () {
        setState(() {
          _list[i] = !_list[i];
        });
      },
      child: Text("Button #${i}"),
    );
  });
  return listButtons;
}
Posted by: Guest on June-25-2020

Code answers related to "flutter button background color"

Browse Popular Code Answers by Language