skip to Main Content

I am trying to install Flutter package "image_picker". When I run flutter pub add image_picker I get the following error:

The current Dart SDK version is 3.0.1.

Because image_picker <0.7.0-nullsafety doesn't support null safety and image_picker >=0.8.4 <0.8.6 depends   
  on image_picker_platform_interface ^2.3.0, image_picker <0.7.0-nullsafety or >=0.8.4 <0.8.6-∞ requires     
  image_picker_platform_interface ^2.3.0.
And because image_picker >=0.8.2 <0.8.4 depends on image_picker_platform_interface ^2.2.0, image_picker
  <0.7.0-nullsafety or >=0.8.2 <0.8.6-∞ requires image_picker_platform_interface ^2.2.0.
And because image_picker >=0.8.1 <0.8.2 depends on image_picker_platform_interface ^2.1.0 and image_picker
  >=0.7.0 <0.8.1 depends on image_picker_platform_interface ^2.0.0, image_picker <0.7.0-nullsafety or >=0.7.0  <0.8.6-∞ requires image_picker_platform_interface ^2.0.0.
Because image_picker_platform_interface >=2.0.0-nullsafety <2.0.0 depends on http ^0.13.0-nullsafety.0 and   
  image_picker >=0.7.0-nullsafety <0.7.0 depends on image_picker_platform_interface ^2.0.0-nullsafety,
  image_picker >=0.7.0-nullsafety <0.7.0 requires http ^0.13.0-nullsafety.0 or
  image_picker_platform_interface ^2.0.0.
Thus, image_picker <0.8.6 requires http ^0.13.0-nullsafety.0 or image_picker_platform_interface ^2.0.0.      
And because image_picker >=0.8.6 depends on image_picker_platform_interface ^2.6.1, every version of
  image_picker requires http ^0.13.0-nullsafety.0 or image_picker_platform_interface ^2.0.0.
And because image_picker_platform_interface >=2.0.0 depends on http ^0.13.0 and google_fonts >=4.0.5
  depends on http ^1.0.0, google_fonts >=4.0.5 is incompatible with image_picker.
So, because favorite_places_app depends on both google_fonts ^4.0.5 and image_picker any, version solving    
  failed.

The lower bound of "sdk: '>=1.8.0 <2.0.0 or >=2.0.0-dev.28.0 <3.0.0'" must be 2.12.0 or higher to enable null safety.
For details, see https://dart.dev/null-safety

I also tried installing the package by inserting the name under dependencies in pubspec.yaml, but same result.

2

Answers


  1. You need to update your pubspec.yaml file to enable null safety feature. Go to pubspec.yaml file and change sdk version under environment

    environment:
      sdk: ">=2.12.0 <3.0.0"
    
    Login or Signup to reply.
  2. adjust your http or google_fonts dependency versions in ‘pubpec.yaml’ file.
    ex> http: ^1.0.1 => ^0.13.0

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search