simplifyNumber function
Simplifies a number into shorter phrases
- Ex. 1,203 => 1.2K
- Ex. 14,593 => 14.5K Will return the same string value if number is less than 1000 Expects a string formatted number and will return a string value. Number needs to be under 1 quadrillion
Implementation
/// Will return the same string value if number is less than 1000
/// Expects a string formatted number and will return a string value.
/// Number needs to be under 1 quadrillion
String simplifyNumber(String value) {
value.contains(RegExp(r'[a-zA-Z]'));
String _cleanedValue = value.replaceAll(RegExp(r','), ' ');
if (int.parse(_cleanedValue) >= 1000) {
int _length = _cleanedValue.length;
return _numberCountLogic(_length, _cleanedValue);
}
///Returns the same value if it's less than 1 thousand
return value;
}