scaledFontSize static method

double scaledFontSize(
  1. BuildContext context, {
  2. required double base,
  3. double min = 10,
  4. double max = 72,
  5. double designWidth = 390,
})

Returns a font size scaled to the current screen width.

base is the font size at the design reference width (default 390). min and max clamp the result.

Implementation

static double scaledFontSize(
  BuildContext context, {
  required double base,
  double min = 10,
  double max = 72,
  double designWidth = 390,
}) {
  final double width = MediaQuery.sizeOf(context).width;
  final double factor = width / designWidth;
  return (base * factor).clamp(min, max);
}