isPDF static method
Determines whether the given file path corresponds to a PDF file.
This method uses the file's magic number (file signature) to accurately detect if the file is a PDF, regardless of its extension. This is more reliable than checking only the file extension.
Parameters:
filePath: The absolute path to the file to check
Returns: true if the file is a valid PDF, false otherwise
(including when an error occurs during detection)
Implementation
static Future<bool> isPDF(String filePath) async {
try {
return await FileMagicNumber.detectFileTypeFromPathOrBlob(filePath) ==
FileMagicNumberType.pdf;
} catch (e) {
return false;
}
}