isImage static method

Future<bool> isImage(
  1. File file
)

判断文件是否为图片

Implementation

static Future<bool> isImage(File file) async {
  try {
    // 读取文件头部数据
    final bytes = await file.readAsBytes();
    return isImageFromBytes(bytes);
  } catch (_) {
    return false;
  }
}