Reputation: 1946
For a Text like:
Text(
'Hello World',
style: Theme.of(context).textTheme.display1,
)
Is there a way to merge textTheme with a TextStyle? Like say, to modify the color of the text..
Upvotes: 2
Views: 1705
Reputation: 23
Merge method causes error in Flutter 2.2 because of the null safety feature. Don't forget to add "?" after the variable.
Theme.of(context).textTheme.display1?.merge(TextStyle(color: Colors.red)
Upvotes: 1
Reputation: 1946
We do something like
Theme.of(context)
.textTheme.display1
.merge(TextStyle(color: Colors.red)
and apply it to the style
Upvotes: 6