'Convert arabic number to english number & the reverse in Dart

I want to replace Arabic number with English number.

1-2-3-4-5-6-7-8-9 <== ١-٢-٣-٤-٥-٦-٧-٨-٩



Solution 1:[1]

Arabic to English

String replaceArabicNumber(String input) {
    const english = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
    const arabic = ['?', '?', '?', '?', '?', '?', '?', '?', '?', '?'];

    for (int i = 0; i < english.length; i++) {
      input = input.replaceAll(arabic[i], english[i]);
    }
    print("$input");
    return input;
  }

to do the opposite replacing the English numbers with the Arabic ones(English to Arabic)

 String replaceEnglishNumber(String input) {
    const english = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
    const arabic = ['?', '?', '?', '?', '?', '?', '?', '?', '?', '?'];

    for (int i = 0; i < english.length; i++) {
      input = input.replaceAll(english[i], arabic[i]);
    }
    print("$input");
    return input;
  }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ruchit