skip to Main Content

I am learning FLutter and started with the deprecated version of TextButton i.e FlatButton the colors seems to work but in TextButton version textColor is not working.

Here’s the code:

Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: <Widget>[
          Text(
            resultPhrase,
            style: TextStyle(fontSize: 36, fontWeight: FontWeight.bold),
          ),
          TextButton(
            child: Text('Restart Quiz!',),
            textColor:Colors.blue,
            onPressed: resetHandler,
          ),
        ],
      ),
    );
  }

I tried Style with foreground colors and it didnt work..am i missing something?
style: TextStyle(color: Colors.purple)
Tried the above through another thread and didnt work.
Is there any way to find most of the descriptions of parameters like they have in Tailwind?

2

Answers


  1. You can use style on TextButton.

    TextButton(
      child: Text('Restart Quiz!',),  
        style: TextButton.styleFrom(
        textStyle: TextStyle(
          color: Colors.blue,
        )
        ),
    
    Login or Signup to reply.
  2. You can access the "style" of the button like this.

    TextButton(
         style: TextButton.styleFrom(
                foregroundColor: Colors.white, //for background color backgroundColor:
                  padding: const EdgeInsets.all(16.0),
                  textStyle: const TextStyle(fontSize: 20),
                ),
                child: const Text('Gradient'),
              ),)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search