LCOV - code coverage report
Current view: top level - theme/typography - foss_typography.dart Coverage Total Hit
Test: fossui coverage Lines: 100.0 % 4 4
Test Date: 2026-11-29 09:15:47 Functions: - 0 0

            Line data    Source code
       1              : // ThemeExtension has no home outside material.dart on the supported SDKs.
       2              : // ignore: deprecated_member_use
       3              : import 'package:flutter/material.dart' show ThemeExtension;
       4              : import 'package:flutter/widgets.dart';
       5              : import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';
       6              : 
       7              : part 'foss_typography.tailor.dart';
       8              : 
       9              : // The bundled font resolves under a package-qualified family name; the bare
      10              : // name would only match a font the consumer declared, so the default scale
      11              : // renders with no setup on their side.
      12              : const _family = 'packages/fossui/Geist';
      13              : 
      14              : /// Text styles per size step. Each carries family, size, line height, and
      15              : /// letter spacing; set weight with the [FossTextStyleWeight] getters (`.medium`
      16              : /// for labels and buttons, `.semibold` for headings, `.bold` for emphasis).
      17              : ///
      18              : /// ```dart
      19              : /// const t = FossTypography.standard;
      20              : /// Text('Label', style: t.sm.medium);
      21              : /// ```
      22              : @TailorMixin(themeGetter: ThemeGetter.none)
      23              : class FossTypography extends ThemeExtension<FossTypography>
      24              :     with _$FossTypographyTailorMixin {
      25              :   /// Creates a type scale. Prefer [standard] unless retheming.
      26            5 :   const FossTypography({
      27              :     required this.xs,
      28              :     required this.sm,
      29              :     required this.base,
      30              :     required this.lg,
      31              :     required this.xl,
      32              :     required this.xl2,
      33              :   });
      34              : 
      35              :   /// 12 px: captions and fine print.
      36              :   @override
      37              :   final TextStyle xs;
      38              : 
      39              :   /// 14 px: the most common body size.
      40              :   @override
      41              :   final TextStyle sm;
      42              : 
      43              :   /// 16 px: body.
      44              :   @override
      45              :   final TextStyle base;
      46              : 
      47              :   /// 18 px: subheadings.
      48              :   @override
      49              :   final TextStyle lg;
      50              : 
      51              :   /// 20 px: headings.
      52              :   @override
      53              :   final TextStyle xl;
      54              : 
      55              :   /// 24 px: large headings.
      56              :   @override
      57              :   final TextStyle xl2;
      58              : 
      59              :   /// The default type scale.
      60              :   static const standard = FossTypography(
      61              :     xs: TextStyle(
      62              :       fontFamily: _family,
      63              :       fontSize: 12,
      64              :       height: 14 / 12,
      65              :       letterSpacing: 0.12,
      66              :     ),
      67              :     sm: TextStyle(fontFamily: _family, fontSize: 14, height: 20 / 14),
      68              :     base: TextStyle(fontFamily: _family, fontSize: 16, height: 24 / 16),
      69              :     lg: TextStyle(
      70              :       fontFamily: _family,
      71              :       fontSize: 18,
      72              :       height: 28 / 18,
      73              :       letterSpacing: -0.18,
      74              :     ),
      75              :     xl: TextStyle(
      76              :       fontFamily: _family,
      77              :       fontSize: 20,
      78              :       height: 28 / 20,
      79              :       letterSpacing: -0.20,
      80              :     ),
      81              :     xl2: TextStyle(
      82              :       fontFamily: _family,
      83              :       fontSize: 24,
      84              :       height: 32 / 24,
      85              :       letterSpacing: -0.36,
      86              :     ),
      87              :   );
      88              : }
      89              : 
      90              : /// Weight conveniences on a [TextStyle], for use on the [FossTypography] scale.
      91              : ///
      92              : /// ```dart
      93              : /// final t = context.fossTheme.typography;
      94              : /// Text('Save', style: t.sm.medium);
      95              : /// Text('Title', style: t.xl.semibold);
      96              : /// ```
      97              : extension FossTextStyleWeight on TextStyle {
      98              :   /// Medium weight (500): labels and buttons.
      99           72 :   TextStyle get medium => copyWith(fontWeight: FontWeight.w500);
     100              : 
     101              :   /// Semibold weight (600): headings.
     102           16 :   TextStyle get semibold => copyWith(fontWeight: FontWeight.w600);
     103              : 
     104              :   /// Bold weight (700): emphasis.
     105            2 :   TextStyle get bold => copyWith(fontWeight: FontWeight.w700);
     106              : }
        

Generated by: LCOV version 2.0-1