I’m creating theme for my app.
I’m confusing these 2 methods (apply, copyWith) of TextStyle.
What should be used?
There’re also 2 methods with the same names in TextTheme.
I understand them, but can not get the idea in TextStyle.
Logic of these 2 in TextStyle is different than in TextTheme
When looking at the docs it shows that
apply uses default values for some parameters if you don’t specify them.
double decorationThicknessFactor = 1.0,
double decorationThicknessDelta = 0.0,
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0,
int fontWeightDelta = 0,
double letterSpacingFactor = 1.0,
double letterSpacingDelta = 0.0,
double wordSpacingFactor = 1.0,
double wordSpacingDelta = 0.0,
double heightFactor = 1.0,
double heightDelta = 0.0,
copywith does not use default values and uses (copies) the values already defined in the original TextStyle object.
It also seems that they have different parameters, for example
apply doesn’t have
fontWeight as a parameter.
Answered By – Er1
Answer Checked By – Pedro (FlutterFixes Volunteer)