AppFontSizesExtension extension

Extension method on BuildContext to calculate responsive font sizes.

This extension provides a convenient way to calculate font sizes that scale proportionally based on screen width, ensuring better readability across different device sizes.

Example:

Text(
  'Hello World',
  style: TextStyle(
    fontSize: context.getResponsiveFontSize(
      smallest: 12,
      largest: 24,
    ),
  ),
)

Recommendations:

  • Use for body text that needs to adapt across mobile, tablet, and desktop
  • For fixed UI elements (like icons), consider using AppFontSizesConstants
  • Combine with AppFontSizesPresets for consistent sizing across your app
on

Methods

getResponsiveFontSize({double? smallest, double? largest, double smallestScreenSize = 320, double largestScreenSize = 1920}) double

Available on BuildContext, provided by the AppFontSizesExtension extension

Calculates a responsive font size based on screen width.