quantityText method
Returns a formatted quantity text based on the provided parameters.
The plural
parameter represents the plural form of the quantity.
The singular
parameter represents the singular form of the quantity. It is optional and defaults to an empty string.
The includeNumber
parameter determines whether to include the quantity number in the text. It is optional and defaults to true.
The method returns a string representing the formatted quantity text.
Implementation
String quantityText(String plural, [String singular = "", bool includeNumber = true, string? locale]) {
var pre = (includeNumber ? toString() : "");
if (plural.isNotBlank) {
if ((this == 1 || this == -1)) {
pre = "$pre ${singular.ifBlank(plural.singular(locale))}";
} else {
pre = "$pre $plural";
}
}
return pre;
}