apply method
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,
),
);
}