calculateFileMD5 static method
计算文件的MD5值
filePath 文件路径
返回 MD5字符串(小写),如果文件不存在或计算失败则返回空字符串
可能抛出 PlatformException 当原生平台调用失败时 可能抛出 ArgumentError 当文件路径无效时
Implementation
static Future<String> calculateFileMD5(String filePath) async {
try {
final result = await _channel.invokeMethod<String>(
'calculateFileMD5',
{'filePath': filePath},
);
return result ?? '';
} on PlatformException catch (e) {
throw PlatformException(
code: e.code,
message: '计算文件MD5失败: ${e.message}',
details: e.details,
);
} catch (e) {
throw Exception('计算文件MD5时发生未知错误: $e');
}
}