Add style to ElevatedButton in Flutter

Add backgroundColor, foregroundColor, borderRadius, text color, minimumSize and maximumSize in Flutter

ElevatedButton(
              style: ElevatedButton.styleFrom(
                // Minimum height and width for ElevatedButton
                  minimumSize: const Size(100, 50),
                  // Maximum height and width for ElevatedButton
                  maximumSize: const Size(200, 100),
                  backgroundColor: Colors.blue,
                  // foregroundColor will appear for short term when you press the button
                  foregroundColor: Colors.yellow,
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(10))),
              onPressed: () {
                //TODO your button action
              },
              child: const Text(
                "Styled Button",
                style: TextStyle(color: Colors.tealAccent),
              ),
            ),

Output:

Leave a Reply