how to style an elevated button in flutter code example

Example 1: elevated button flutter color

ElevatedButton(
  style: ButtonStyle(
    backgroundColor: MaterialStateProperty.resolveWith<Color>(
      (Set<MaterialState> states) {
        if (states.contains(MaterialState.pressed))
          return Colors.green;
        return null; // Use the component's default.
      },
    ),
  ),
)

Example 2: Flutter Elevated button color

ElevatedButton(
            child: Text('Button'),
            onPressed: () {},
            style: ButtonStyle(
                backgroundColor: MaterialStateProperty.all(Colors.red),
                padding: MaterialStateProperty.all(EdgeInsets.all(50)),
                textStyle: MaterialStateProperty.all(TextStyle(fontSize: 30))),
),

Example 3: flutter elevated button

ElevatedButton(
      onPressed: () {},
      child: Text('Submit'),
    );

Example 4: how to style an elevated button in flutter

elevatedButton

Tags:

Misc Example