toTomanString function

String toTomanString(
  1. String s, {
  2. bool fromRial = false,
})

Implementation

String toTomanString(String s, {bool fromRial = false}) {
  s = digitToEnglish(s);
  if (int.tryParse(s) == null || int.parse(s).isNegative) {
    throw Exception('$s is invalid.');
  }
  if (fromRial) s = s.substring(0, s.length - 1);
  s = digitToFarsiString(s);
  return '$s تومان';
}