copyWith method

ShadTextTheme copyWith({
  1. TextStyle? h1Large,
  2. TextStyle? h1,
  3. TextStyle? h2,
  4. TextStyle? h3,
  5. TextStyle? h4,
  6. TextStyle? p,
  7. TextStyle? blockquote,
  8. TextStyle? table,
  9. TextStyle? list,
  10. TextStyle? lead,
  11. TextStyle? large,
  12. TextStyle? small,
  13. TextStyle? muted,
  14. String? family,
  15. String? package,
  16. GoogleFontBuilder? googleFontBuilder,
  17. Map<String, TextStyle>? custom,
})

Implementation

ShadTextTheme copyWith({
  TextStyle? h1Large,
  TextStyle? h1,
  TextStyle? h2,
  TextStyle? h3,
  TextStyle? h4,
  TextStyle? p,
  TextStyle? blockquote,
  TextStyle? table,
  TextStyle? list,
  TextStyle? lead,
  TextStyle? large,
  TextStyle? small,
  TextStyle? muted,
  String? family,
  String? package,
  GoogleFontBuilder? googleFontBuilder,
  Map<String, TextStyle>? custom,
}) {
  final baseFamily = family ?? this.family;
  late final String effectiveFamily;
  if (package != null && package.isNotEmpty) {
    final alreadyPrefixed = baseFamily.startsWith('packages/');
    effectiveFamily =
        !alreadyPrefixed //
        ? 'packages/$package/$baseFamily'
        : baseFamily;
  } else {
    effectiveFamily = baseFamily;
  }

  return ShadTextTheme.custom(
    canMerge: canMerge,
    h1Large: h1Large ?? this.h1Large,
    h1: h1 ?? this.h1,
    h2: h2 ?? this.h2,
    h3: h3 ?? this.h3,
    h4: h4 ?? this.h4,
    p: p ?? this.p,
    blockquote: blockquote ?? this.blockquote,
    table: table ?? this.table,
    list: list ?? this.list,
    lead: lead ?? this.lead,
    large: large ?? this.large,
    small: small ?? this.small,
    muted: muted ?? this.muted,
    family: effectiveFamily,
    googleFontBuilder: googleFontBuilder ?? this.googleFontBuilder,
    custom: custom ?? this.custom,
  );
}