Flutter Upgrade Issue

646 Views Asked by At

I upgraded my flutter to 2.2.0. But is showing an error like this:

Because mockito >=5.0.8 depends on code_builder ^4.0.0 and build_runner >=0.9.1+1 <2.0.0 depends on code_builder >2.3.0 <4.0.0, mockito >=5.0.8 is incompatible with build_runner >=0.9.1+1 <2.0.0. So, because cost_of_care depends on both build_runner ^1.11.0 and mockito ^5.0.8, version solving failed. pub get failed (1; So, because cost_of_care depends on both build_runner ^1.11.0 and mockito ^5.0.8, version solving failed.) Exited (1)

Please tell me what is this error and how I can fix it. I already upgraded all my dependencies to the latest.

This is my pubspec.yaml

name: cost_of_care
description: A new Flutter application.
publish_to: "none"
version: 1.0.2+3
environment:
  sdk: ">=2.8.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.3
  html: ^0.15.0
  shimmer: ^2.0.0
  geocoding: ^2.0.0
  bloc: ^7.0.0
  flutter_bloc: ^7.0.0
  equatable: ^2.0.2
  cached_network_image: ^3.0.0
  file_utils: ^1.0.0
  hive: ^2.0.4
  hive_flutter: ^1.0.0
  dio: ^4.0.0
  flutter_cache_manager: ^3.0.2
  share: ^0.6.5+4
  url_launcher: ^6.0.4
  bloc_test: ^8.0.0
  gps: ^0.1.1
  permission_handler: ^8.0.0+1
  package_info: ^2.0.0
  app_settings: ^4.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  hive_generator: ^1.1.0
  build_runner: ^1.11.0
  mockito: ^5.0.8
  flutter_launcher_icons: ^0.9.0
  change_app_package_name: ^0.1.3

depedency_overrides:
  path: 1.7.0
  build_runner: ^1.11.0
  mockito: ^5.0.8


flutter_icons:
  ios: true
  android: true
  image_path_ios: "assets/app_icon.png"
  image_path_android: "assets/app_icon.png"

flutter:
  uses-material-design: true
  assets:
    - assets/app_icon.png
    - assets/compare_data.csv
    - assets/distance_icon.png
    - assets/hospital_compare.jpg
    - assets/intro2.jpg
    - assets/libre_white.png
    - assets/librehealth.png
    - assets/logowhite.png
    - assets/placeholder.png
    - assets/
  fonts:
    - family: Source
      fonts:
        - asset: fonts/SourceSansPro-Regular.ttf
          weight: 300
        - asset: fonts/SourceSansPro-SemiBold.ttf
          weight: 600
2

There are 2 best solutions below

0
On

The error seems to be quite clear.

Your latest version of mockito needs the higher version of code_builder but your build_runner version is too low to support it.

There is a later version of build_runner available, which is build_runner: ^2.0.3 which supports code_builder: ^4.0.0.

So, in your pubsec.yaml, just change your build_runner version to ^2.0.3 wherever you have it.

That should be fixing it.

0
On

This is a dependency issues, one by one check errors and change the library version for example enter link description here version

flutter pub get
#check error
#replace that library with higher or lower version accordingly
#After update
flutter pub get