Want to convert english number with farsi number in Dart? Use the following example code to convert english number with farsi number.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | String replaceFarsiNumber(String input) { const english = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; const farsi = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; for (int i = 0; i < english.length; i++) { input = input.replaceAll(english[i], farsi[i]); } return input; } main() { print(replaceFarsiNumber('0-1-2-3-4-5-6-7-8-9')); // ==> ۰-۱-۲-۳-۴-۵-۶-۷-۸-۹ } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.