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. double letterSpacingFactor = 1.0,
  7. double letterSpacingDelta = 0.0,
  8. double wordSpacingFactor = 1.0,
  9. double wordSpacingDelta = 0.0,
  10. double heightFactor = 1.0,
  11. double heightDelta = 0.0,
  12. Color? displayColor,
  13. Color? bodyColor,
  14. TextDecoration? decoration,
  15. Color? decorationColor,
  16. 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,
  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,
}) {
  return TextTheme(
    displayLarge: displayLarge?.apply(
      color: displayColor,
      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,
    ),
    displayMedium: displayMedium?.apply(
      color: displayColor,
      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,
    ),
    displaySmall: displaySmall?.apply(
      color: displayColor,
      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,
    ),
    headlineLarge: headlineLarge?.apply(
      color: displayColor,
      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,
    ),
    headlineMedium: headlineMedium?.apply(
      color: displayColor,
      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,
    ),
    headlineSmall: headlineSmall?.apply(
      color: bodyColor,
      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,
    ),
    titleLarge: titleLarge?.apply(
      color: bodyColor,
      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,
    ),
    titleMedium: titleMedium?.apply(
      color: bodyColor,
      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,
    ),
    titleSmall: titleSmall?.apply(
      color: bodyColor,
      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,
    ),
    bodyLarge: bodyLarge?.apply(
      color: bodyColor,
      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,
    ),
    bodyMedium: bodyMedium?.apply(
      color: bodyColor,
      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,
    ),
    bodySmall: bodySmall?.apply(
      color: displayColor,
      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,
    ),
    labelLarge: labelLarge?.apply(
      color: bodyColor,
      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,
    ),
    labelMedium: labelMedium?.apply(
      color: bodyColor,
      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,
    ),
    labelSmall: labelSmall?.apply(
      color: bodyColor,
      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,
    ),
  );
}