I'm trying to apply blue color on Theme.of(context).textTheme.headline6, it can be done in two ways
Text(
"Hello",
style: Theme.of(context)
.textTheme
.headline6!
.copyWith(color: Colors.blue),
),
or
Text(
"Hello",
style: Theme.of(context)
.textTheme
.headline6!
.apply(color: Colors.blue),
),
Which one you prefer copyWith or apply method?
Preview on image
The main difference is that apply() offers several parameters to scale parameters of the source TextStyle.
For example, copyWith(fontSize: 14) lets you explicitly set the font size, while apply(fontSizeFactor: 1.6) lets you scale the source's font size by a custom factor (note that an explicit fontSize parameter does not exist in apply()).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With