Anurag Arwalkar
Anurag Arwalkar

Reputation: 725

How to change TextButton text color in Flutter

How to change default TextButton text color in flutter here is my code

TextButton(onPressed: null, child: Text('Add Item'))

Upvotes: 1

Views: 7731

Answers (2)

Abdulbari Mohamed
Abdulbari Mohamed

Reputation: 11

TextButton(
    style: TextButton.styleFrom(
        backgroundColor: Colors."anyColour", // if you want to change button colour
    ),
    
    child: Text('Your Text here',
        style: TextStyle(
        color: Colors."anyColour", // this is for your text colour
    ),
),

So your codes goes like this I believe

TextButton(onPressed: null, 
    child: Text('Add Item',
    style: TextStyle(
    color: Colors."anyColour",
    ),
),

Upvotes: 0

Anurag Arwalkar
Anurag Arwalkar

Reputation: 725

Just add style property to Text constructor if you are not using a theme

TextButton(onPressed: null, child: Text('Add Item', 
style: TextStyle(color: Colors.purple)))

If You are using the default theme in the main.dart file then it will pick the accentColor or u can manually also provide

TextButton(onPressed: null, child: Text('Add Item', 
style: TextStyle(color: Theme.of(context).accentColor)))

Upvotes: 3

Related Questions