copyWith method
Typeface
copyWith({
- Chrome? palette,
- TextTheme? background,
- TextTheme? foreground,
- TextTheme? primary,
- TextTheme? secondary,
- TextTheme? ascent,
- TextTheme? onPrimary,
- TextTheme? onSecondary,
- TextTheme? onAscent,
- TextTheme? success,
- TextTheme? error,
- TextTheme? warning,
- TextTheme? parent,
- TextTheme? child,
override
Creates a copy of this theme extension with the given fields replaced by the non-null parameter values.
Implementation
@override
Typeface copyWith({
Chrome? palette,
TextTheme? background,
TextTheme? foreground,
//...surface
TextTheme? primary,
TextTheme? secondary,
TextTheme? ascent,
//...on surface
TextTheme? onPrimary,
TextTheme? onSecondary,
TextTheme? onAscent,
//...extras
TextTheme? success,
TextTheme? error,
TextTheme? warning,
TextTheme? parent,
TextTheme? child,
}) {
//...
TextTheme sudo(TextTheme theme, color, nxt) {
var arch = (parent ?? theme).merge(theme); //...parenting
arch = arch.apply(displayColor: color, bodyColor: color);
return arch.merge(nxt).merge(child);
}
return Typeface(
background: sudo(this.background, palette?.background, background),
foreground: sudo(this.foreground, palette?.foreground, foreground),
//...surface
primary: sudo(this.primary, palette?.primary, primary),
secondary: sudo(this.secondary, palette?.secondary, secondary),
ascent: sudo(this.ascent, palette?.ascent, ascent),
//...on surface
onPrimary: sudo(this.onPrimary, palette?.onPrimary, onPrimary),
onSecondary: sudo(this.onSecondary, palette?.onSecondary, onSecondary),
onAscent: sudo(this.onAscent, palette?.onAscent, onAscent),
//...extras
success: sudo(this.success, palette?.success, success),
error: sudo(this.error, palette?.error, error),
warning: sudo(this.warning, palette?.warning, warning),
);
}