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):
- bodySmall - Smallest readable text (captions, footnotes)
- body - Standard body text (paragraphs, lists)
- bodyLarge - Emphasized body text
- paragraphTitle - Small headings within paragraphs
- subheader - Section subheadings
- header - Main section headings
- h3 - Third-level headings
- h2 - Second-level headings
- h1 - Top-level headings
- 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
scaleFactorbased on your design system:small(1.13): Compact, information-dense layoutsnormal(1.17): Balanced, general-purposelarge(1.27): Clear hierarchy, better readabilityextraLarge(1.62): Golden ratio, maximum distinction
See also:
- AppFontSizesPresets for ready-to-use size configurations
- AppFontSizesScaleFactors for available scale factor options
- AppFontSizesConstants for compile-time constant font sizes
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
- header → double
-
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