change color of elevated button flutter code example
Example 1: elevated button flutter color
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith(
(Set states) {
if (states.contains(MaterialState.pressed))
return Colors.green;
return null; // Use the component's default.
},
),
),
)
Example 2: elevated Button Theme background color in flutter
style: ElevatedButton.styleFrom(
primary: Colors.purple,
),