wordsToNumberString function
String?
wordsToNumberString(
- String words, {
- DigitLocale digits = DigitLocale.en,
- bool addComma = false,
Returns equivalent number in String of the given words.
With DigitLocale enum you can determine language of the digits in returned String.
With addComma
parameter you can determine the returned String has comma or not.
Implementation
String? wordsToNumberString(
String words, {
DigitLocale digits = DigitLocale.en,
bool addComma = false,
}) {
final computeNumbers = wordsToNumber(words);
if (computeNumbers == null) return null;
final addedCommasIfNeeded =
addComma ? computeNumbers.addComma : computeNumbers.toString();
switch (digits) {
case DigitLocale.fa:
return convertEnToFa(addedCommasIfNeeded);
case DigitLocale.ar:
return convertEnToAr(addedCommasIfNeeded);
case DigitLocale.en:
default:
return addedCommasIfNeeded;
}
}