There is probably something obvious I'm missing. Is there one property that can change the color of all the text in a Flutter app?
The way I am doing it now is, in my MaterialApp:
theme: ThemeData(
textTheme: Theme.of(context).textTheme.copyWith(
body1:
Theme.of(context).textTheme.body1.apply(color: Colors.pink),
body2:
Theme.of(context).textTheme.body2.apply(color: Colors.pink),
display1:
Theme.of(context).textTheme.display1.apply(color: Colors.pink),
display2:
Theme.of(context).textTheme.display2.apply(color: Colors.pink),
... // and so on
),
),
),
I also tried
textTheme: Theme.of(context).textTheme.apply(bodyColor: Colors.pink),
but this applies to Dropdown text, not regular text. Likewise, displayColor
applies to the appBar text and a InputDecoration text, but not regular text. I don't seem to have any decorationText
in my code so I'm not sure what that one is for.
I note there is a textSelectionColor
property but that only applies for TextField
widgets.
To provide an alternative that seems to work without setting all the Text styles directly is to change the style of the
DefaultTextStyle
at the place in the Widget tree to take effectFor the entire app, you can set
textTheme
property inMaterial
app.Maybe a bit late... but you can use this:
I think
TextTheme.apply
is what you want.bodyColor
will be applied toheadline
,title
,subhead
,button
,body1
, andbody2
.displayColor
will be applied todisplay1
throughdisplay4
, andcaption
. If you specify bothbodyColor
anddisplayColor
and use the same color value, that will effectively change text colors on all text styles.Example: