apply method

TextTheme apply({
  1. String? fontFamily,
  2. List<String>? fontFamilyFallback,
  3. String? package,
  4. double fontSizeFactor = 1.0,
  5. double fontSizeDelta = 0.0,
  6. Color? displayColor,
  7. Color? bodyColor,
  8. TextDecoration? decoration,
  9. Color? decorationColor,
  10. TextDecorationStyle? decorationStyle,
})

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,
  Color? displayColor,
  Color? bodyColor,
  TextDecoration? decoration,
  Color? decorationColor,
  TextDecorationStyle? decorationStyle,
}) {
  return TextTheme(
    displayLarge: displayLarge?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    displayMedium: displayMedium?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    displaySmall: displaySmall?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    headlineLarge: headlineLarge?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    headlineMedium: headlineMedium?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    headlineSmall: headlineSmall?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    titleLarge: titleLarge?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    titleMedium: titleMedium?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    titleSmall: titleSmall?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    bodyLarge: bodyLarge?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    bodyMedium: bodyMedium?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    bodySmall: bodySmall?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    labelLarge: labelLarge?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    labelMedium: labelMedium?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
    labelSmall: labelSmall?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontFamilyFallback: fontFamilyFallback,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
      package: package,
    ),
  );
}