nearestFontWeight function

FontWeight nearestFontWeight(
  1. double weight
)

The FontWeight closest to a CSS weight (clamped to 100–900).

Implementation

FontWeight nearestFontWeight(double weight) {
  final index = ((weight.clamp(100, 900) - 100) / 100).round();
  return FontWeight.values[index];
}