
final List<String> persianNums = ['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹'];

String persianalizeNum(String txt){
  String newTxt = '';
  for(int i=0, length=txt.length; i<length; i++){
    int? num = int.tryParse(txt[i]);
    newTxt += num == null ? txt[i] : persianNums[num];
  }
  return newTxt;
}

String? divideNum(String txt){
  if(txt == null || txt == ''){
    return null;
  }
  return txt.replaceAll(RegExp(r"\B(?=(.{3})+(?!.))"), ',');
}

String formatNum(String txt, {bool persianalize = false, bool divide = true, String? suffix}){
  if(divide){
    txt = divideNum(txt)!;
  }
  if(persianalize){
    txt = persianalizeNum(txt);
  }
  return suffix == null ? txt : '$txt$suffix';
}