getFileExtension static method
get file extension
Implementation
static String getFileExtension(String? path, {bool withDot = true}) {
String extension = "";
if (withDot) {
if (!Files._isNullOREmpty(path)) {
if (path.toString().contains(".")) {
extension =
path.toString().substring(path.toString().lastIndexOf("."));
} else {
extension = ".${path.toString()}";
}
}
} else {
if (!Files._isNullOREmpty(path)) {
if (path.toString().contains(".")) {
extension =
(path.toString().substring(path.toString().lastIndexOf(".")))
.replaceAll(".", "");
} else {
extension = path.toString();
}
}
}
return extension;
}