compensatedFontWeight static method

FontWeight compensatedFontWeight(
  1. int baseWeight,
  2. double scaleFactor
)

Implementation

static FontWeight compensatedFontWeight(int baseWeight, double scaleFactor) {
  int compensated;
  if (scaleFactor <= 1.0) {
    compensated = baseWeight;
  } else if (scaleFactor >= 2.0) {
    compensated = 100;
  } else {
    final t = (scaleFactor - 1.0) / 1.0;
    compensated = (baseWeight - t * (baseWeight - 100)).toInt().clamp(
      100,
      baseWeight,
    );
  }
  // Round to nearest hundred for Flutter's FontWeight
  return FontWeight.values[(compensated / 100).round().clamp(1, 9) - 1];
}