close

How to Change Background color of Elevated Button in Flutter

Hello guys how are you all? Hope you all are fine. As we know RaisedButton is deprecated and the Elevated button is replacing Raised Button widget with its new features. Here in this tutorial, we are going to learn How to Change Background color of Elevated Button in Flutter.

How to Change Background color of Elevated Button in Flutter

Suppose we need to change Elevated Button Background color then? Elevated Button has a style Property And style property need ButtonStyle(). ButtonStyle has backgroundColor property which requires MaterialStateProperty. You can simply assign background color by MaterialStateProperty.all<Color>(Colors.green). Let’s explore examples of Background color of Elevated Button in Flutter.

Example

            ElevatedButton(
              onPressed: () {
                print('Button Pressed');
              },
              style: ButtonStyle(
                backgroundColor: MaterialStateProperty.all<Color>(Colors.green),
              ),
              child: Text('FlutterCorner.com'),
            ),

Output

How to Change Background color of Elevated Button in Flutter,

Faq

  1. How to Change Background color of Elevated Button in Flutter ?

    to Change Background color of Elevated Button in Flutter Elevated Button has a style Property And style property need ButtonStyle(). ButtonStyle has backgroundColor property which requires MaterialStateProperty. You can simply assign background color by MaterialStateProperty.all<Color>(Colors.green).

  2. Change Background color of Elevated Button in Flutter ?

    Change Background color of Elevated Button in Flutter Elevated Button has a style Property And style property need ButtonStyle(). ButtonStyle has backgroundColor property which requires MaterialStateProperty. You can simply assign background color by MaterialStateProperty.all<Color>(Colors.green).

Summery

So it’s all About this tutorial. Hope this above-all solution helped you a lot. Comment below Your thoughts and your queries. Comment Below on your suggestion.

Check Out Below Article

Leave a Comment

%d bloggers like this: