Ahmadre / image_picker_web

A picker with which you can pick images and videos from your Flutter web app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

After clicking the image picker, the dialog appears, but when clicking on cancel, the loader is not dismissing

ilmobileteam opened this issue · comments

Below is the code for selecting a video for the web. However, when the dialog appears and the user clicks cancel, the CustomLoader is not getting dismissed. The line of code "await ImagePickerWeb.getImageInfo;" is not getting executed.
imagePicker() async {
try {
final fromPicker = await ImagePickerWeb.getImageInfo;
CustomLoader.show();
if (fromPicker!.fileName!.isNotEmpty) {
int imageCount = 0;
//Count the number of image files in the list
final kb = await ((await fromPicker!.data!.lengthInBytes) / 1024);
final mb = kb / 1024;
if (mb > 10) {
errorSnackBar(content: 'For image maximum limit is 10mb.');
CustomLoader.dismiss();
} else if (mb == 0) {
errorSnackBar(content: 'For image maximum limit is 10mb.');
CustomLoader.dismiss();
} else {
for (var item in filePathTypeList) {
if (item.type == 'image') {
imageCount++;
}
}
if (imageCount >= 4) {
errorSnackBar(content: 'Maximum 4 images can be uploaded');
} else {
filePathTypeList.add(FileWebDetails(
path: Rx(fromPicker!.data!),
type: 'image',
originalPath: fromPicker.fileName!));
}
}
} else {
CustomLoader.dismiss();
}
CustomLoader.dismiss();
logger(
message: e.toString(),
);
} catch (e) {
CustomLoader.dismiss();
logger(
title: "Video Picker error",
message: e.toString(),
);
}
}

I can reproduce, seems like getImageInfo and getVideoInfo are not completing properly when cancelled. There was a similar issue on the classic picker, I'll have to see if I can apply the same workaround.

That will be great, thanks @TesteurManiak