Home > Enterprise >  How to implement and find good version of plugins in Flutter?
How to implement and find good version of plugins in Flutter?

Time:03-24

Dart version 2.13.4

Flutter version 2.2.3

How to implement retrofit, I have tried many many options and always I have got errors with versions. How do you handle this issues easily it is a nightmare :C :)

version: 1.0.0 1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  aad_oauth: ^0.3.0
  animated_splash_screen: ^1.1.0
  auto_size_text: ^2.1.0
#  build_runner: ^2.1.1
  cloud_firestore: ^2.5.4
  cupertino_icons: ^1.0.2
  date_time_picker: ^2.1.0
  dio: ^4.0.0
  easy_localization: ^3.0.0
  equatable: ^2.0.3
  fast_immutable_collections: ^7.0.3
  file_picker: ^4.1.1
  firebase_auth: ^3.1.0
  firebase_storage: ^10.0.3
  flutter:
    sdk: flutter
  flutter_form_builder: ^6.1.0 1
  flutter_mobx: ^2.0.2
  flutter_multiselect: ^1.0.0
  flutter_slidable: ^0.6.0
  flutter_svg: ^0.22.0
  get: ^4.3.8
  http: ^0.13.3
  image_picker: any
#  json_annotation: ^4.1.0
#  json_serializable: ^5.0.0
  kartal: ^2.1.0
  lottie: ^1.2.1
  mime: ^1.0.1
  mime_type: ^1.0.0
  mobx: ^2.0.4
  mobx_codegen: any
  multi_select_flutter: ^4.0.0
  numberpicker: ^2.1.1
  path: ^1.8.0
  path_provider: any
  provider: ^6.0.0
  shared_preferences: ^2.0.7
  url_launcher: any
  vexana: ^2.3.0
  webview_flutter: ^2.0.4


  retrofit: any
#  dio: ^3.0.10
  built_value: ^7.1.0
  json_annotation: any
#  build_runner: ^1.10.0
#  json_serializable: ^3.5.0



dependency_overrides:
  analyzer: ^2.1.0
  meta: ^1.4.0
  firebase_messaging_platform_interface: 3.1.6
  firebase_crashlytics_platform_interface: 3.1.13
  cloud_firestore_platform_interface: 5.4.13
  firebase_auth_platform_interface: 6.1.11
  firebase_storage_platform_interface: 4.0.14
  cloud_functions_platform_interface: 5.0.21
  firebase_analytics_platform_interface: 3.0.5
  firebase_remote_config_platform_interface: 1.0.5
  firebase_dynamic_links_platform_interface: 0.2.0 5
  firebase_performance_platform_interface: 0.1.0 5
  firebase_app_installations_platform_interface: 0.1.0 6

dev_dependencies:
  flutter_test:
    sdk: flutter

#  retrofit_generator: ^1.3.7 5
#  build_runner: ^1.10.0
#  json_serializable: ^3.5.0
#  built_value_generator: ^7.1.0

  build_runner: ^1.4.0
#  json_serializable: any
  retrofit_generator: any
  built_value_generator: any

flutter:
  uses-material-design: true
  assets:
    - assets/lang/
    - assets/svg/
    - assets/image/
    - assets/lottie/

  fonts:
    - family: Poppins
      fonts:
        - asset: assets/fonts/Poppins-Regular.ttf

How do you fix that kind of issues?

The current Dart SDK version is 2.13.4.

Because built_value >=6.1.0 <8.0.0-nullsafety.0 depends on built_collection >=2.0.0 <5.0.0 and retrofit_generator >=2.0.0-beta1 <4.0.0 depends on built_collection ^5.0.0, built_value >=6.1.0 <8.0.0-nullsafety.0 is incompatible with retrofit_generator >=2.0.0-beta1 <4.0.0.
Because retrofit_generator >=0.6.3 1 <1.0.0 depends on dio 2.1.16 and retrofit_generator <=0.6.3 depends on dio ^2.1.0, retrofit_generator <1.0.0 requires dio ^2.1.0.
Thus, if built_value >=6.1.0 <8.0.0-nullsafety.0 and retrofit_generator <1.0.0-∞ or >=2.0.0-beta1 <4.0.0-∞ then dio ^2.1.0.
And because retrofit_generator >=1.0.0 <2.0.0-beta1 depends on dio ^3.0.1, if built_value >=6.1.0 <8.0.0-nullsafety.0 and retrofit_generator <4.0.0 then dio ^2.1.0 or ^3.0.1.
And because retrofit_generator >=4.0.0 requires SDK version >=2.14.0 <3.0.0 and mdi_flutter_proj depends on dio ^4.0.0, built_value >=6.1.0 <8.0.0-nullsafety.0 is incompatible with retrofit_generator.
So, because mdi_flutter_proj depends on both built_value ^7.1.0 and retrofit_generator any, version solving failed.
pub get failed (1; So, because mdi_flutter_proj depends on both built_value ^7.1.0 and retrofit_generator any, version solving failed.)
Process finished with exit code 1

It is not only code, but just few piece of information so I write here some text to have the possibility of applying my post.

CodePudding user response:

Run following command in terminal : flutter pub upgrade--major-versions

CodePudding user response:

first you must increase dart sdk version to 2.14 then you can upgrade retrofit generator

therefore you can upgrade build collection because null safety version I know its confusing at first because when you use so many third party package different package can use different versioning for certain package like retrofit package in you example

usually you WANT to upgrade your package using to null safety package asap for this reason you can change versioning package you using by look on package page on pub.dev

tldr: if you lazy like me :) you can use this command

flutter pub upgrade 

in this example I have updated 4 my plugin/package I use you can see there are mismatch version constraint on ur pubspec yaml

Downloading fluentui_system_icons 1.1.162...
Downloading go_router 3.0.5...
Downloading win32 2.4.4...
Changed 4 dependencies!
15 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

then I pub upgrade run to upgrade all my package to match the constraint of my pubspec yaml on this line

environment:
  sdk: ">=2.16.0 <3.0.0"

that way update will update all of your package to match depedency constraint you using right now

 flutter pub upgrade --major-versions

disclaimer this is not recommended way, you must update package manually because usually there are deprecated API that you must change in certain version

  • Related