md5OfFile function
获取md5
当文件大小超过streamThreshold
时, 启用流式处理, 避免大文件干爆内存
Implementation
Future<String> md5OfFile(
File file, {
int streamThreshold = 10 * 1024 * 1024,
}) async {
if (await file.length() > streamThreshold) {
final stream = file.openRead();
return md5.bind(stream).first.then(toString);
} else {
return md5Of(await file.readAsBytes());
}
}