toKMB static method
String
toKMB(
- int counter,
- String singularName,
- String pluralName, [
- NumberUnits unit = NumberUnits.auto,
Converts a counter value to a formatted string with unit.
Example: (1500, 'item', 'items', Counter.kmb) -> '1.5k items'
Implementation
static String toKMB(
int counter,
String singularName,
String pluralName, [
NumberUnits unit = NumberUnits.auto,
]) {
if (counter > 1) {
return "${unit.read(counter).text} $pluralName";
} else {
return "$counter $singularName";
}
}