compact static method

String compact(
  1. double value, {
  2. String? locale,
})

Compact number: 1.2K, 1.5M, etc.

Implementation

static String compact(double value, {String? locale}) {
  final key = 'compact_${locale ?? 'en'}';
  final fmt = _numCache.putIfAbsent(
    key,
    () => NumberFormat.compact(locale: locale),
  );
  return fmt.format(value);
}