-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathutils.dart
35 lines (27 loc) · 1.01 KB
/
utils.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
String formatDuration(Duration position) {
final ms = position.inMilliseconds;
int seconds = ms ~/ 1000;
final int hours = seconds ~/ 3600;
seconds = seconds % 3600;
var minutes = seconds ~/ 60;
seconds = seconds % 60;
final hoursString = hours >= 10 ? '$hours' : hours == 0 ? '00' : '0$hours';
final minutesString =
minutes >= 10 ? '$minutes' : minutes == 0 ? '00' : '0$minutes';
final secondsString =
seconds >= 10 ? '$seconds' : seconds == 0 ? '00' : '0$seconds';
final formattedTime =
'${hoursString == '00' ? '' : hoursString + ':'}$minutesString:$secondsString';
return formattedTime;
}
///isRtlLanguage return bool rtl
///RegExp is taken from intl dart package
bool isRtlLanguage(String language) {
final _rtlLocaleRegex = RegExp(
r'^(ar|dv|he|iw|fa|nqo|ps|sd|ug|ur|yi|.*[-_]'
r'(Arab|Hebr|Thaa|Nkoo|Tfng))(?!.*[-_](Latn|Cyrl)($|-|_))'
r'($|-|_)',
caseSensitive: false);
final bool _rtlCheck = _rtlLocaleRegex.hasMatch(language);
return _rtlCheck;
}