scaledFontSize static method
double
scaledFontSize(
- BuildContext context, {
- required double base,
- double min = 10,
- double max = 72,
- 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);
}