pick method
- HatangAttachmentSource source
Lets the visitor pick from source; null when they cancel.
Implementation
Future<UploadSource?> pick(HatangAttachmentSource source) async {
switch (source) {
case HatangAttachmentSource.camera:
case HatangAttachmentSource.gallery:
final x = await _images.pickImage(
source: source == HatangAttachmentSource.camera ? ImageSource.camera : ImageSource.gallery,
maxWidth: maxImageSide.toDouble(),
maxHeight: maxImageSide.toDouble(),
imageQuality: jpegQuality,
requestFullMetadata: false,
);
if (x == null) return null;
return await prepare(await x.readAsBytes(), x.name, x.mimeType);
case HatangAttachmentSource.file:
final pick = _pickFile;
if (pick == null) return null;
final f = await pick();
if (f == null) return null;
return await prepare(f.bytes, f.name, f.mimeType);
}
}