Search code examples
flutterflutter-layoutflutter-dependenciesflutter-test

How to solve multi dependency version conflicts simply?


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.


Solution

  • 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