pickFile method
Future<FilePickResult?>
pickFile({
- List<
String> ? allowedExtensions, - void onProgress()?,
- ValueNotifier<
bool> ? canceled, - bool returnStream = true,
- bool calcMD5 = true,
- bool returnBlob = true,
override
Implementation
@override
Future<FilePickResult?> pickFile({
List<String>? allowedExtensions,
void Function(bool done, double progress)? onProgress,
ValueNotifier<bool>? canceled,
bool returnStream = true,
bool calcMD5 = true,
bool returnBlob = true,
}) async {
final result = await FilePickerExtendedWeb.platform.pickFiles(
type: FileType.custom,
allowedExtensions: allowedExtensions,
withData: false,
withReadStream: returnStream,
allowCompression: false,
allowMultiple: false);
if (result == null || result.files.isEmpty || result.files2.isEmpty) {
throw Exception('No files picked or file picker was canceled');
}
if (result.files.isNotEmpty) {
var res = FilePickResult(
length: result.files.first.size,
stream: returnStream ? result.files.first.readStream! : null,
blob: returnBlob ? result.files2.first : null,
md5: calcMD5
? await MD5Util.calculate(
result.files2.first,
size: result.files.first.size,
onProgress: onProgress,
canceled: canceled,
)
: null,
fileName: result.files.first.name,
);
if (!(canceled?.value ?? false)) {
if (calcMD5 && null == res.md5) {
return null;
} else {
return res;
}
}
}
return null;
// throw Exception('No files picked or file picker was canceled');
}