formatMaxChars method
- int maxChars = 1
Returns input as a formatted string with a maximum amount of characters. For example, when maxChars = 1, any number over 9 will return '9+'.
maxChars
defaults to one.
Typically used for notifications.
Implementation
String formatMaxChars([int maxChars = 1]) {
final strVal = this == null ? '' : this!.abs().toString();
return strVal.length > maxChars ? '${'9' * maxChars}+' : strVal;
}