When looking at the docs it shows that apply
uses default values for some parameters if you don't specify them.
TextStyle apply(
{Color? color,
Color? backgroundColor,
TextDecoration? decoration,
Color? decorationColor,
TextDecorationStyle? decorationStyle,
double decorationThicknessFactor = 1.0,
double decorationThicknessDelta = 0.0,
String? fontFamily,
List? fontFamilyFallback,
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0,
int fontWeightDelta = 0,
FontStyle? fontStyle,
double letterSpacingFactor = 1.0,
double letterSpacingDelta = 0.0,
double wordSpacingFactor = 1.0,
double wordSpacingDelta = 0.0,
double heightFactor = 1.0,
double heightDelta = 0.0,
TextBaseline? textBaseline,
TextLeadingDistribution? leadingDistribution,
Locale? locale,
List? shadows,
List? fontFeatures}
)
https://api.flutter.dev/flutter/painting/TextStyle/apply.html
copywith
does not use default values and uses (copies) the values already defined in the original TextStyle object.
TextStyle copyWith(
{bool? inherit,
Color? color,
Color? backgroundColor,
String? fontFamily,
List? fontFamilyFallback,
double? fontSize,
FontWeight? fontWeight,
FontStyle? fontStyle,
double? letterSpacing,
double? wordSpacing,
TextBaseline? textBaseline,
double? height,
TextLeadingDistribution? leadingDistribution,
Locale? locale,
Paint? foreground,
Paint? background,
List? shadows,
List? fontFeatures,
TextDecoration? decoration,
Color? decorationColor,
TextDecorationStyle? decorationStyle,
double? decorationThickness,
String? debugLabel}
)
https://api.flutter.dev/flutter/painting/TextStyle/copyWith.html
Edit:
It also seems that they have different parameters, for example apply
doesn't have fontSize
and fontWeight
as a parameter.