-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_extension.dart
51 lines (43 loc) · 1.04 KB
/
file_extension.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import 'dart:io';
extension FileExtesion on FileSystemEntity {
String get nameWithType {
return path.split('/').last;
}
String get secondPath {
String a = path.split('/').elementAt(2);
return a;
}
String get mainStoragePath {
String a = path.split('/').elementAt(1);
String b = path.split('/').elementAt(2);
String c = path.split('/').elementAt(3);
return '/$a/$b/$c/';
}
String get sdCardStoragePath {
String a = path.split('/').elementAt(1);
String b = path.split('/').elementAt(2);
return '/$a/$b/';
}
String get nameWithoutType {
//abc.mp3
//0123456
if (isMp3) {
return nameWithType.replaceRange(nameWithType.length - 4, null, '');
} else if (isM4a) {
return nameWithType.replaceRange(nameWithType.length - 4, null, '');
}
return nameWithType;
}
bool get isMp3 {
if (nameWithType.endsWith('.mp3')) {
return true;
}
return false;
}
bool get isM4a {
if (nameWithType.endsWith('.m4a')) {
return true;
}
return false;
}
}