pickImage method
Open the image dialog picker
Implementation
Future<void> pickImage({final int? maxSize, final Function()? onAdd}) async {
print("object");
await FilePicker.platform.pickFiles(
type : FileType.custom,
allowedExtensions : _fileTypes,
lockParentWindow : true,
allowMultiple : false,
withData : true
).then((response) async {
if (response == null) {
reset(error: false);
} else {
final f = response.files.single;
if(!_fileTypes.contains(f.extension)) {
reset(error: false);
} else {
await setFromBytes(
name : f.name,
extension : f.extension ?? '',
bytes : f.bytes,
maxSize : maxSize,
).then((_) {
onAdd?.call();
});
}
}
notifyListeners();
})
.onError((error, stackTrace) => reset(error: false));
}