ImagePicker _picker = ImagePicker(); // from image_picker.dart
try {
XFile? pickedFile = await _picker.pickImage(source: source);
do xyz;
}
catch (e){
...something
}
vs
try {
_picker.pickImage(source: source).then((file) {do xyz;});
}
catch (e){
...something
}
The file select dialog opens. If I cancel without selecting a file, this is the behavior:
Case 1: await - neither 'do xyz' or the catch block is executed - the function just returns
case 2: then - the 'do xyz' block is executed
What is going on?