AppFontSizes class

A flexible font sizing system with hierarchical typography scales.

This class provides a complete typographic scale based on a customizable base size (bodySmall) and a geometric scale factor. It follows a consistent progression from small body text to large display headings.

Typography Hierarchy (from smallest to largest):

  1. bodySmall - Smallest readable text (captions, footnotes)
  2. body - Standard body text (paragraphs, lists)
  3. bodyLarge - Emphasized body text
  4. paragraphTitle - Small headings within paragraphs
  5. subheader - Section subheadings
  6. header - Main section headings
  7. h3 - Third-level headings
  8. h2 - Second-level headings
  9. h1 - Top-level headings
  10. display - Hero text, large titles

Usage:

// Create a custom font size scale
final customSizes = AppFontSizes(
  bodySmall: 16,
  scaleFactor: AppFontSizesScaleFactors.normal,
);

Text(
  'Heading',
  style: TextStyle(fontSize: customSizes.h1),
);

Text(
  'Body text',
  style: TextStyle(fontSize: customSizes.body),
);

Recommendations:

  • Use AppFontSizesPresets for common size configurations
  • Use AppFontSizesConstants for compile-time constant values
  • Choose a scaleFactor based on your design system:
    • small (1.13): Compact, information-dense layouts
    • normal (1.17): Balanced, general-purpose
    • large (1.27): Clear hierarchy, better readability
    • extraLarge (1.62): Golden ratio, maximum distinction

See also:

Constructors

AppFontSizes({double bodySmall = AppFontSizesConstants.bodySmall, double scaleFactor = AppFontSizesScaleFactors.large})
Creates a font sizing system with the specified base size and scale factor.

Properties

body double
Standard body text size.
no setter
bodyLarge double
Emphasized or larger body text.
no setter
bodySmall double
The smallest text size in the hierarchy.
no setter
display double
Display text for hero sections and large titles.
no setter
h1 double
Top-level heading (H1).
no setter
h2 double
Second-level heading (H2).
no setter
h3 double
Third-level heading (H3).
no setter
hashCode int
The hash code for this object.
no setterinherited
Main section headings.
no setter
paragraphTitle double
Small headings within content blocks.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subheader double
Subheadings for content sections.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited