Flutter: Version solving failed in pub get

3.2k views Asked by At

Situation

I just cloned a Flutter project in which my colleagues are working on, but I cannot make it work on my laptop. I am using a Macbook Pro, the same as them. It works for them, but not for me.

The problem is at flutter pub get or flutter upgrade. This is the error:

Resolving dependencies...

Note: intl is pinned to version 0.18.1 by flutter_localizations from the flutter SDK. See https://dart.dev/go/sdk-version-pinning for details.

Because trooms depends on flutter_localizations from sdk which depends on intl 0.18.1, intl 0.18.1 is required. So, because trooms depends on intl ^0.17.0, version solving failed.

Process finished with exit code 1

And these are my dependencies:

name: trooms
description: Web, Android and iOS App for TROOMS.
publish_to: 'none' 
version: 1.0.0+1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
    
  cupertino_icons: ^1.0.4
  intl: 0.18.1
  json_serializable: ^6.1.6
  json_annotation: ^4.4.0
  firebase_core: ^2.0.3
  firebase_auth: ^4.1.3
  cloud_firestore: ^4.1.0
  firebase_analytics: ^10.0.6
  firebase_crashlytics: ^3.0.6
  firebase_performance: ^0.9.0+6
  firebase_storage: ^11.0.6
  image_picker: ^0.8.6
  flutter_image_slideshow: ^0.1.4
  cloud_functions: ^4.0.5
  logging: ^1.0.2
  flutter_riverpod: ^2.1.1
  flutter_launcher_icons: ^0.11.0
  font_awesome_flutter: ^10.1.0
  flutterfire_ui: ^0.4.0+2
  url_launcher: ^6.0.20
  beamer: ^1.5.3
  q_form:
    git:
      url: //url
  flutter_native_splash: ^2.1.5
  date_time_picker: ^2.1.0
  table_calendar: ^3.0.5
  flutter_beacon: ^0.5.1
  google_fonts: ^3.0.1

dev_dependencies:
  flutter_app_name: ^0.1.1
  build_runner: ^2.1.10
  fake_cloud_firestore: ^2.0.1
  firebase_auth_mocks: ^0.9.1
  firebase_storage_mocks: ^0.6.0+1
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.1
  get: ^4.6.1

flutter_app_name:
  name: "TROOMS"

flutter_icons:
  android: true
  ios: true
  remove_alpha_ios: true
  image_path: "assets/icon/trooms-ulm-logo.png"
  adaptive_icon_background: #ffffff
  flutter_lints: ^1.0.4

flutter:
  uses-material-design: true
  generate: true
  assets:
  - assets/
  - assets/icon/

First attempted solution

I tried changing the SDK to the same as them but it did not work. I can't downgrade Flutter to their exact same version, for some reason:

~ TROOMS % flutter downgrade v3.7.7

Downgrade flutter to version 3.3.9

? [y|n]:

Second attempted solution

Then, I changed the intl package version to the one required: intl: 0.18.1. This is the new error with that:

Resolving dependencies...

Because date_time_picker 2.1.0 depends on intl ^0.17.0 and no versions of date_time_picker match >2.1.0 <3.0.0, date_time_picker ^2.1.0 requires intl ^0.17.0. So, because trooms depends on both intl 0.18.1 and date_time_picker ^2.1.0, version solving failed.

Process finished with exit code 1

Third attempted solution

I also tried changing flutter_localizations to any like this

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations: any

But it's also not accepted:

Resolving dependencies...

Because trooms depends on flutter_localizations any which doesn't exist (could not find package flutter_localizations at https://pub.dev), version solving failed.

Process finished with exit code 69

I did the same for intl. Same output.

Questions

So it seems that the packages date_time_picker and flutter_localizations both depend on different versions of intl, which is not compatible and that's why it fails. So, how can I solve packages having different pinned versions of the same dependency?

BUT why I'm confused is because the exact same code does work for my colleages, having the same dependencies, although we do have different SDKs. Could the SDK have something to do?

1

There are 1 answers

1
belinda.g.freitas On BEST ANSWER

I think from Flutter >= 3.10 (do some research yourself to be sure), flutter_localizations require intl >= 0.18.0. So there's 2 solutions:

  • if date_time_picker has a version which use newer version of Flutter, use it instead,
  • downgrade your Flutter SDK to a version that support intl 0.17.0.