apply method
TextTheme
apply({
- String? fontFamily,
- List<
String> ? fontFamilyFallback, - String? package,
- double fontSizeFactor = 1.0,
- double fontSizeDelta = 0.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,
- Color? displayColor,
- Color? bodyColor,
- TextDecoration? decoration,
- Color? decorationColor,
- TextDecorationStyle? decorationStyle,
- List<
FontFeature> ? fontFeatures, - List<
FontVariation> ? fontVariations,
Creates a copy of this text theme but with the given field replaced in each of the individual text styles.
The displayColor is applied to displayLarge, displayMedium,
displaySmall, headlineLarge, headlineMedium, and bodySmall. The
bodyColor is applied to the remaining text styles.
Consider using Typography.black or Typography.white, which implement the typography styles in the Material Design specification, as a starting point.
Implementation
TextTheme apply({
String? fontFamily,
List<String>? fontFamilyFallback,
String? package,
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.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,
Color? displayColor,
Color? bodyColor,
TextDecoration? decoration,
Color? decorationColor,
TextDecorationStyle? decorationStyle,
List<FontFeature>? fontFeatures,
List<FontVariation>? fontVariations,
}) {
TextStyle? applyTo(TextStyle? style, Color? color) => style?.apply(
color: color,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontFamilyFallback: fontFamilyFallback,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta,
letterSpacingDelta: letterSpacingDelta,
letterSpacingFactor: letterSpacingFactor,
wordSpacingDelta: wordSpacingDelta,
wordSpacingFactor: wordSpacingFactor,
heightFactor: heightFactor,
heightDelta: heightDelta,
package: package,
fontFeatures: fontFeatures,
fontVariations: fontVariations,
);
return TextTheme(
displayLarge: applyTo(displayLarge, displayColor),
displayMedium: applyTo(displayMedium, displayColor),
displaySmall: applyTo(displaySmall, displayColor),
headlineLarge: applyTo(headlineLarge, displayColor),
headlineMedium: applyTo(headlineMedium, displayColor),
headlineSmall: applyTo(headlineSmall, bodyColor),
titleLarge: applyTo(titleLarge, bodyColor),
titleMedium: applyTo(titleMedium, bodyColor),
titleSmall: applyTo(titleSmall, bodyColor),
bodyLarge: applyTo(bodyLarge, bodyColor),
bodyMedium: applyTo(bodyMedium, bodyColor),
bodySmall: applyTo(bodySmall, displayColor),
labelLarge: applyTo(labelLarge, bodyColor),
labelMedium: applyTo(labelMedium, bodyColor),
labelSmall: applyTo(labelSmall, bodyColor),
);
}