This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension StringExtentions on String { | |
| String replaceFaNumToEnNum() { | |
| const english = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; | |
| const farsi = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; | |
| String value = this; | |
| for (int i = 0; i < farsi.length; i++) { | |
| value = value.replaceAll(farsi[i], english[i]); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static String formatBytes(int bytes, int decimals) { | |
| if (bytes <= 0) return "0 B"; | |
| const suffixes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; | |
| var i = (log(bytes) / log(1024)).floor(); | |
| return ((bytes / pow(1024, i)).toStringAsFixed(decimals)) + | |
| ' ' + | |
| suffixes[i]; | |
| } |