adjust method
TextStyle
adjust({
- double? sizeMultiplier,
- int? weightStep,
- double? fontSize,
- FontWeight? fontWeight,
- Color? color,
- bool clearColor = false,
- Color? backgroundColor,
- double? letterSpacing,
- double? wordSpacing,
- double? height,
- Paint? foreground,
- Paint? background,
- TextDecoration? decoration,
- Color? decorationColor,
- TextDecorationStyle? decorationStyle,
- double? decorationThickness,
- String? fontFamily,
- List<
String> ? fontFamilyFallback, - List<
Shadow> ? shadows, - FontStyle? fontStyle,
Returns a new TextStyle with adjusted properties such as sizeMultiplier and weightStep.
sizeMultiplier: MultipliesfontSizeby this factor (iffontSizeis not null).weightStep: Steps thefontWeightby an offset (e.g. +1 changes w100 to w200, w300 to w400; -1 makes it lighter). IffontWeightis currently null, defaults to FontWeight.normal before stepping.- All other parameters standardly override properties via copyWith.
Implementation
TextStyle adjust({
double? sizeMultiplier,
int? weightStep,
double? fontSize,
FontWeight? fontWeight,
Color? color,
bool clearColor = false,
Color? backgroundColor,
double? letterSpacing,
double? wordSpacing,
double? height,
Paint? foreground,
Paint? background,
TextDecoration? decoration,
Color? decorationColor,
TextDecorationStyle? decorationStyle,
double? decorationThickness,
String? fontFamily,
List<String>? fontFamilyFallback,
List<Shadow>? shadows,
FontStyle? fontStyle,
}) {
final effectiveFontSize =
fontSize ?? (sizeMultiplier != null && this.fontSize != null ? this.fontSize! * sizeMultiplier : this.fontSize);
final effectiveFontWeight =
fontWeight ?? (weightStep != null ? (this.fontWeight ?? FontWeight.normal).step(weightStep) : this.fontWeight);
if (clearColor) {
return TextStyle(
inherit: inherit,
color: null,
backgroundColor: backgroundColor ?? this.backgroundColor,
fontSize: effectiveFontSize,
fontWeight: effectiveFontWeight,
fontStyle: fontStyle ?? this.fontStyle,
letterSpacing: letterSpacing ?? this.letterSpacing,
wordSpacing: wordSpacing ?? this.wordSpacing,
textBaseline: textBaseline,
height: height ?? this.height,
leadingDistribution: leadingDistribution,
locale: locale,
foreground: foreground ?? this.foreground,
background: background ?? this.background,
shadows: shadows ?? this.shadows,
fontFeatures: fontFeatures,
fontVariations: fontVariations,
decoration: decoration ?? this.decoration,
decorationColor: decorationColor ?? this.decorationColor,
decorationStyle: decorationStyle ?? this.decorationStyle,
decorationThickness: decorationThickness ?? this.decorationThickness,
debugLabel: debugLabel,
fontFamily: fontFamily ?? this.fontFamily,
fontFamilyFallback: fontFamilyFallback ?? this.fontFamilyFallback,
overflow: overflow,
);
}
return copyWith(
fontSize: effectiveFontSize,
fontWeight: effectiveFontWeight,
color: color,
backgroundColor: backgroundColor,
letterSpacing: letterSpacing,
wordSpacing: wordSpacing,
height: height,
foreground: foreground,
background: background,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
decorationThickness: decorationThickness,
fontFamily: fontFamily,
fontFamilyFallback: fontFamilyFallback,
shadows: shadows,
fontStyle: fontStyle,
);
}