getFileExtension method
Extracts the file extension from a given file path.
filePath is the path of the file.
Returns the file extension as a string.
Implementation
String getFileExtension(String filePath) {
int lastDotIndex = filePath.lastIndexOf('.');
if (lastDotIndex != -1 && lastDotIndex != 0) {
return filePath.substring(lastDotIndex + 1);
} else {
return '';
}
}