apply method
Typeface
apply(
{ - Chrome? chrome,
- TextStyle? background,
- TextStyle? foreground,
- TextStyle? primary,
- TextStyle? secondary,
- TextStyle? ascent,
- TextStyle? onPrimary,
- TextStyle? onSecondary,
- TextStyle? onAscent,
- TextStyle? success,
- TextStyle? error,
- TextStyle? warning,
- TextStyle? all,
})
Implementation
Typeface apply({
Chrome? chrome,
TextStyle? background,
TextStyle? foreground,
//...surface
TextStyle? primary,
TextStyle? secondary,
TextStyle? ascent,
//...on surface
TextStyle? onPrimary,
TextStyle? onSecondary,
TextStyle? onAscent,
//...extras
TextStyle? success,
TextStyle? error,
TextStyle? warning,
TextStyle? all,
}) {
//...
TextStyle merge(style, color) {
//...
style = style?.copyWith(colors: color);
return style ?? TextStyle(color: color);
}
TextTheme apply(TextTheme original, TextStyle? other) {
//...
return original.apply(
bodyColor: other?.color ?? all?.color,
displayColor: other?.color ?? all?.color,
fontFamily: other?.fontFamily ?? all?.fontFamily,
decoration: other?.decoration ?? all?.decoration,
decorationColor: other?.decorationColor ?? all?.decorationColor,
decorationStyle: other?.decorationStyle ?? all?.decorationStyle,
);
}
return Typeface(
background: apply(this.background, merge(background, chrome?.background)),
foreground: apply(this.foreground, merge(foreground, chrome?.foreground)),
//...surface
primary: apply(this.primary, merge(primary, chrome?.primary)),
secondary: apply(this.secondary, merge(secondary, chrome?.secondary)),
ascent: apply(this.ascent, merge(ascent, chrome?.ascent)),
//...on surface
onPrimary: apply(this.onPrimary, merge(onPrimary, chrome?.onPrimary)),
onSecondary: apply(this.onSecondary, merge(onSecondary, chrome?.onSecondary)),
onAscent: apply(this.onAscent, merge(onAscent, chrome?.onAscent)),
//...extras
success: apply(this.success, merge(success, chrome?.success)),
error: apply(this.error, merge(error, chrome?.error)),
warning: apply(this.warning, merge(warning, chrome?.warning)),
);
}