1

Any suggestions to change the color of the ElevateButton below?

child: ElevatedButton(
                                child: Text(
                                  'Subscribe',
                                  style: TextStyle(
                                      color: gray900,
                                      fontFamily: 'Lexend Exa',
                                      fontSize: 20),
                                ),
                                onPressed: fetchOffersMonthly,
                              ),
CountryMusic
  • 115
  • 1
  • 6
  • this might answer your question, https://stackoverflow.com/questions/66835173/how-to-change-background-color-of-elevated-button-in-flutter-from-function – towhid Oct 04 '21 at 05:10

3 Answers3

0

Use ButtonStyle to change the color

 ElevatedButton(
    style: ButtonStyle(
    backgroundColor: MaterialStateProperty.all<Color>(Colors.green)),
    onPressed: () {  }, 
    child: Text(""),
 ),
Ananda Pramono
  • 899
  • 1
  • 6
  • 18
0

Try below code hope its helpful to you. refer documentation Here for ElevatedButton

ElevatedButton(
       style: ElevatedButton.styleFrom(
                 primary: Colors.red,//choose your color on your need
                ),
           child: Text(
            'Subscribe',
               style: TextStyle(
                 color: gray900,
                  fontFamily: 'Lexend Exa',
                  fontSize: 20),
                ),
                onPressed: fetchOffersMonthly,
              ),

Your result screen -> Image

Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40
0
ElevatedButton(
        child: Text('Subscribe'),
        onPressed: () {},
        style: ElevatedButton.styleFrom(
            primary: Colors.purple,
            textStyle: TextStyle(
              fontSize: 30,
              fontWeight: FontWeight.bold),
      ),
    )
Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40
  • 3
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 04 '21 at 05:37
  • 3
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. You can find more information on how to write good answers in the help center: https://stackoverflow.com/help/how-to-answer . Good luck – nima Oct 04 '21 at 09:19