5

I have imported a project in android studio flutter. But, there is an incredible amount of version conflict coming in. If one solves other rises and if that goes down, other one rises. I am trying to get all packages and it is showing me the following error as below.

Because date_utils >=0.1.0+3 depends on intl ^0.16.0 and prokit_flutter depends on intl 0.17.0-nullsafety.2, date_utils >=0.1.0+3 is forbidden.
So, because prokit_flutter depends on date_utils ^0.1.0+3, version solving failed.

pub get failed (1; So, because prokit_flutter depends on date_utils ^0.1.0+3, version solving failed.)
Process finished with exit code 1

And my pubspec.yaml code is as below.

name: prokit_flutter
description: A new Flutter application.
version: 1.0.0+1

environment:
  sdk: ">=2.6.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.0
  url_launcher: 5.0.3
  nb_utils: 3.1.6+7
  google_fonts: 1.1.0
  animations: 1.1.2
  intl: 0.17.0-nullsafety.2
  http: 0.12.2
  firebase_core: 0.5.0
  firebase_analytics: 6.0.0
  firebase_crashlytics: 0.1.4+1
  google_sign_in: 4.5.3
  html: 0.14.0+3
  share: 0.6.5
  mobx: ^1.2.1+2
  flutter_mobx: ^1.1.0+2

  flutter_statusbarcolor: 0.2.3
  simple_animations: 1.3.8
  snaplist: 0.1.8
  flutter_svg: 0.18.1
  flutter_slidable: 0.5.7
  flutter_staggered_grid_view: 0.3.2
  flutter_staggered_animations: 0.1.2

  geolocator: 5.3.2+2
  geocoder: 0.2.1
  google_maps_flutter: 0.5.21+3
  clustering_google_maps: 0.1.2
  razorpay_flutter: 1.2.2
  signature: 3.2.0
  liquid_swipe: 1.5.0
  lipsum: 1.0.1
  flutter_colorpicker: 0.3.4
  clippy_flutter: 1.1.1
  flutter_tags: ^0.4.8
  image_picker_gallery_camera: 0.1.6
  video_player: 0.10.11+2
  charts_flutter: ^0.9.0
  like_button: ^1.0.1
  flutter_reaction_button: ^1.0.1
  lottie: ^0.6.0
  showcaseview: ^0.1.6
  date_utils: ^0.1.0+3
  cached_network_image: ^2.3.1

  flutter_localizations:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter
  mobx_codegen:
  build_runner: ^1.9.0
  #flutter packages pub run build_runner build

flutter:

  uses-material-design: true

  assets:
    - images/smartDeck/images/

  fonts:
    - family: Andina
      fonts:
        - asset: fonts/andina.ttf

And there are 4-5 dependency version error. How can I solve this version error thing in one click or I can just somehow skip this version problem and get the thing done. Please help, Thanks in Advance.

Appolonias
  • 88
  • 1
  • 8

6 Answers6

20

Whenever conflicts between dependencies occur, the simplest solution is to just remove the version number of both that dependencies and type 'any' without quotes in front of them.

for example let's say this following two dependency conflicts:

shared_preferences: ^0.5.7+3  
requests: ^3.3.0

then do following:

shared_preferences: any  
requests: any

After this do pub get and issue will be resolved. Now, most importantly, don't leave any dependency on this form. instead goto pubspec.lock file and search these two dependencies. Flutter itself chooses the versions that don't conflict, copy those and replace it to pubsec.yaml

Anas Yousuf
  • 423
  • 1
  • 6
  • 17
  • Thank you but what an involved method! Flutter team. please create a 'flutter pub doctor' tool to manage these kind of situations. – marco110 Jul 09 '22 at 18:48
6

You can use dependency_overrides in your pubspec.yaml to force a specific package version. The package version will override any reference to a dependency in the entire app.

In your case you could use

dependencies:
  flutter:
    sdk: flutter
  ...

  cupertino_icons: ^1.0.0

dependency_overrides:
  intl: ^0.17.0-nullsafety.2

See dependency_overrides for more information.

Maggin
  • 61
  • 2
1

had the same problem; ran the following command:

flutter pub upgrade --major-versions

if you don't mind having the latest version of all the dependencies while solving version conflict issues, this should be a quick fix.

0

Replace intl: 0.17.0-nullsafety.2 version with intl: 0.16.1 and remove intl from dependency overrides. Now, run pub get command.

Bhoomin Naik
  • 402
  • 4
  • 7
0

You can simply change the version of package that is causing conflic with another version which is compatible with your dart SDK. I tried it and the problem was solved.

Fahima Mokhtari
  • 1,691
  • 2
  • 16
  • 30
0

I had this problem after resetting my Mac mini.

If you still have the pubspec.lock file at the last successful run (or get it from another dev, on that dev's computer the project is still running).

  1. flutter clean.
  2. Replace pubspec.lock by the old one.
  3. Run the project again.
Thang Tran
  • 171
  • 1
  • 5