appTextStyleTemplate function

String appTextStyleTemplate()

Implementation

String appTextStyleTemplate() => '''
${ProjectUtils.fileGenerationString}

import 'package:flutter/material.dart';

extension AppTextStyleContext on BuildContext {
  AppTextStyles get appTextStyles => AppTextStyles(this);
}

class AppTextStyles {
  final BuildContext context;

  const AppTextStyles(this.context);

  TextTheme get _text => Theme.of(context).textTheme;

  /// Base typography (shared)
  static const TextTheme baseTextTheme = TextTheme(
    headlineLarge: TextStyle(fontSize: 28, fontWeight: FontWeight.w600),
    headlineMedium: TextStyle(fontSize: 24, fontWeight: FontWeight.w600),
    headlineSmall: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),

    titleLarge: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
    titleMedium: TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
    titleSmall: TextStyle(fontSize: 12, fontWeight: FontWeight.w600),

    bodyLarge: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
    bodyMedium: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
    bodySmall: TextStyle(fontSize: 12, fontWeight: FontWeight.w500),

    labelLarge: TextStyle(fontSize: 14, fontWeight: FontWeight.w400),
    labelMedium: TextStyle(fontSize: 12, fontWeight: FontWeight.w400),
    labelSmall: TextStyle(fontSize: 11, fontWeight: FontWeight.w400),
  );

  // ================= REGULAR (w400) =================

  /// Regular 12px
  TextStyle get regular12 => _text.labelMedium!;

  /// Regular 14px
  TextStyle get regular14 => _text.labelLarge!;

  /// Regular 16px
  TextStyle get regular16 => _text.labelLarge!.copyWith(fontSize: 16);

  /// Regular 18px
  TextStyle get regular18 => _text.labelLarge!.copyWith(fontSize: 18);

  // ================= MEDIUM (w500) =================

  /// Medium 12px
  TextStyle get medium12 => _text.bodySmall!;

  /// Medium 14px
  TextStyle get medium14 => _text.bodyMedium!;

  /// Medium 16px
  TextStyle get medium16 => _text.bodyLarge!;

  /// Medium 18px
  TextStyle get medium18 => _text.bodyLarge!.copyWith(fontSize: 18);

  // ================= SEMIBOLD (w600) =================

  /// SemiBold 12px
  TextStyle get semiBold12 => _text.titleSmall!;

  /// SemiBold 14px
  TextStyle get semiBold14 => _text.titleMedium!;

  /// SemiBold 16px
  TextStyle get semiBold16 => _text.titleLarge!;

  /// SemiBold 18px
  TextStyle get semiBold18 => _text.titleLarge!.copyWith(fontSize: 18);

  // ================= BOLD (w700) =================

  /// Bold 12px
  TextStyle get bold12 => _text.titleSmall!.copyWith(fontWeight: FontWeight.w700);

  /// Bold 14px
  TextStyle get bold14 => _text.titleMedium!.copyWith(fontWeight: FontWeight.w700);

  /// Bold 16px
  TextStyle get bold16 => _text.titleLarge!.copyWith(fontWeight: FontWeight.w700);

  /// Bold 18px
  TextStyle get bold18 => _text.titleLarge!.copyWith(fontWeight: FontWeight.w700, fontSize: 18);

  /// Bold 32px
  TextStyle get bold32 => _text.titleLarge!.copyWith(fontWeight: FontWeight.w700, fontSize: 32);

  /// Bold 40px
  TextStyle get bold40 => _text.titleLarge!.copyWith(fontWeight: FontWeight.w700, fontSize: 40);

  /// Fully customizable text style
  /// Uses theme defaults and allows safe overrides
  TextStyle custom({
    double? size,
    FontWeight? weight,
    Color? color,
    FontStyle? style,
    double? letterSpacing,
    double? height,
    TextDecoration? decoration,
    TextOverflow? overflow,
  }) {
    return _text.bodyMedium!.copyWith(
      fontSize: size,
      fontWeight: weight,
      color: color,
      fontStyle: style,
      letterSpacing: letterSpacing,
      height: height,
      decoration: decoration,
      overflow: overflow,
    );
  }
}
''';