Error: Type 'ImagePickerOptions' not found

Viewed 23

I'm getting this error each time I run my code after I added plugin image_picker: ^0.8.5+3 from flutter pub dev I cannot see any errors. I have already tried running flutter doctor no issues displayed. I am using flutter 3.3.1. I have tried cleaning my project using flutter clean and even cleared the project cache but no luck. I also tried lowering the version of the plugin from image_picker: ^0.8.5+3 to image_picker: ^0.8.5+2 but still got the error below.

Launching lib\main.dart on Z90 in debug mode...
lib\main.dart:1
: Error: Type 'ImagePickerOptions' not found.../…/lib/image_picker_android.dart:174
    ImagePickerOptions options = const ImagePickerOptions(),
    ^^^^^^^^^^^^^^^^^^

: Error: Couldn't find constructor 'ImagePickerOptions'.../…/lib/image_picker_android.dart:174
    ImagePickerOptions options = const ImagePickerOptions(),
                                       ^^^^^^^^^^^^^^^^^^
: Error: 'ImagePickerOptions' isn't a type.../…/lib/image_picker_android.dart:174
    ImagePickerOptions options = const ImagePickerOptions(),
    ^^^^^^^^^^^^^^^^^^

Here is the only place I have used the image_picker

Future pickImage(ImageSource source, String field, ValueChanged<String> uploadCompleted) async {
    ImagePicker imagePicker = ImagePicker();
    XFile pickedFile = await imagePicker.pickImage(source: source, imageQuality: 80);
    File imageFile = File(pickedFile.path);
    print(imageFile);
    if (imageFile != null) {
      try {
        uploading.value = true;
        await deleteUploaded();
        uuid = await _uploadRepository.image(imageFile, field);
        image.value = imageFile;
        uploadCompleted(uuid);
        uploading.value = false;
      } catch (e) {
        uploading.value = false;
        Get.showSnackbar(Ui.ErrorSnackBar(message: e.toString()));
      }
    } else {
      uploading.value = false;
      Get.showSnackbar(Ui.ErrorSnackBar(message: "Please select an image file".tr));
    }
  }
0 Answers
Related