apply method Null safety

TextTheme apply(
  1. {String? fontFamily,
  2. double fontSizeFactor = 1.0,
  3. double fontSizeDelta = 0.0,
  4. Color? displayColor,
  5. Color? bodyColor,
  6. TextDecoration? decoration,
  7. Color? decorationColor,
  8. 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,
  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,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    displayMedium: displayMedium?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    displaySmall: displaySmall?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    headlineLarge: headlineLarge?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    headlineMedium: headlineMedium?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    headlineSmall: headlineSmall?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    titleLarge: titleLarge?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    titleMedium: titleMedium?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    titleSmall: titleSmall?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    bodyLarge: bodyLarge?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    bodyMedium: bodyMedium?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    bodySmall: bodySmall?.apply(
      color: displayColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    labelLarge: labelLarge?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    labelMedium: labelMedium?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
    labelSmall: labelSmall?.apply(
      color: bodyColor,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      fontFamily: fontFamily,
      fontSizeFactor: fontSizeFactor,
      fontSizeDelta: fontSizeDelta,
    ),
  );
}