copyWith method

  1. @override
Typeface copyWith({
  1. Chrome? palette,
  2. TextTheme? background,
  3. TextTheme? foreground,
  4. TextTheme? primary,
  5. TextTheme? secondary,
  6. TextTheme? ascent,
  7. TextTheme? onPrimary,
  8. TextTheme? onSecondary,
  9. TextTheme? onAscent,
  10. TextTheme? success,
  11. TextTheme? error,
  12. TextTheme? warning,
  13. TextTheme? parent,
  14. 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),
  );
}