getFileExtension function
Returns only the extensions in the file path. If unknown, returns null'.
Implementation
String? getFileExtension(String filePath, {bool? isWindows = false}) {
String strPath = filePath.split(isWindows == true ? '\\' : '/').last;
if (strPath.isEmpty) {
return null;
}
strPath = extension(strPath).isNotEmpty ? extension(strPath) : strPath;
if (!strPath.contains('.')) {
return null;
}
return strPath.split('.').last.toLowerCase();
}