2

I installed image_picker in my Flutter app through $ flutter pub add image_picker.
Currently, the latest version is 1.0.1, but in my pubspec.yaml file i get version 0.7.2+1.

Since "Starting with version 0.8.2 of the image_picker plugin, new methods have been added" (e.g. ImagePicker().getImage(...) is now ImagePicker().pickImage(...)), I can't use these methods.

I tried to manually change the version to 1.0.1, but when I run $ flutter pub get I get the following error:

Because image_picker >=1.0.1 depends on image_picker_for_web ^2.2.0 which depends on flutter_web_plugins from sdk, image_picker >=1.0.1 requires flutter_web_plugins from sdk.
So, because flutter_web_plugins from sdk doesn't exist (could not find package flutter_web_plugins in the Flutter SDK) and my_app depends on image_picker ^1.0.1, version solving failed.
exit code 69

Here is my pubspec.yaml file after creating the app with $ flutter create my_app and adding the dependency with $ flutter pub add image_picker:

name: my_app
description: A new Flutter project.
publish_to: 'none' 

version: 1.0.0+1

environment:
  sdk: '>=3.0.5 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  image_picker: ^0.7.2+1

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0


flutter:
  uses-material-design: true

Siddharth Mehra
  • 1,691
  • 1
  • 9
  • 32
VicAl02
  • 23
  • 4

1 Answers1

0

The error message kinda clear. You could do this 2 solutions:

  • Upgrade Flutter to use the latest Flutter version, which exists flutter_web_plugins inside that.
  • Just use the old version of image_picker that doesn't requires flutter_web_plugins.

If you're maintaining old project & don't care/want to use latest version, use solution 2.

Nguyen family
  • 749
  • 2
  • 12