Flutter - How to change color of the text - 2022

In app development, without design, we can't imagine the app, We can also count the color combination of the app according to the app theme, Sometimes we need to change the color of the text using a text widget which is the most usable widget for any application. So we can change the color of the text widget in various ways like below

1. Using style properties.

We can use style properties to change the color of the text widget like

Text(
  'Errorgram',
  style: TextStyle(color: Colors.red),//Change color here
)

 

2. Using theme.

We can change globally the color of the text widget using the theme. By default, every text widget text color is set to red in entire the app.

MaterialApp(
  title: 'Errorgram',
  theme: ThemeData(
    textTheme:
        TextTheme(headline2: TextStyle(color: Colors.red), //Change color here
), ),);

I hope you like this article and it will be help to you.

Tags: