loadFile method
dynamic
loadFile(
- dynamic formname,
- dynamic item,
- dynamic id,
- dynamic context,
Implementation
loadFile(formname, item, id, context) async {
myLogAll('loadFile');
if (isNull(formname)) {
return;
}
removeOverlay();
FilePickerResult? result = await pickFiles();
if (result == null || result.files.isEmpty) {
throw Exception('Cannot read file from null stream');
}
var file = result.files.first;
//var filePath = file.path;
var filename = file.name;
final fileReadStream = file.readStream;
if (fileReadStream == null) {
throw Exception('Cannot read file from null stream');
}
if (file.size > 1048576) {
throw Exception('file size can not be over 1M');
}
final stream = http.ByteStream(fileReadStream);
uploadToServer(context, filename, stream, file.size, formname, item, id);
}