isImage static method
Determines whether the given file path corresponds to an image file.
The method checks for common image file extensions (.jpg, .jpeg, .png,
.gif, .bmp). If the file has no extension, it is assumed to be an image.
Implementation
static Future<bool> isImage(String filePath) async {
try {
final fileType =
await FileMagicNumber.detectFileTypeFromPathOrBlob(filePath);
return fileType == FileMagicNumberType.png ||
fileType == FileMagicNumberType.jpg;
} catch (e) {
return false;
}
}