Because every version of flutter_driver from sdk depends on crypto 2.1.5 and Cruise depends on crypto 3.0.0, flutter_driver from sdk is forbidden

Viewed 4057

when I compile my project in fedora 32, shows this error:

Running "flutter pub get" in cruise-open...
Because every version of flutter_driver from sdk depends on crypto 2.1.5 and Cruise depends on crypto 3.0.0, flutter_driver from sdk is forbidden.
So, because Cruise depends on flutter_driver any from sdk, version solving failed.
pub get failed (1; So, because Cruise depends on flutter_driver any from sdk, version solving failed.)

this is my pubspec.yaml file:

name: Cruise
description: A RSS article read Flutter application.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  intl: 0.17.0
  meta: ^1.1.8
  flutter_svg: 0.19.0
  logger: 0.9.4
  scoped_model: ^1.1.0
  shrine_images: ^1.1.2
  flare_dart: 2.3.4
  flare_flutter: ^2.0.2
  vector_math: ^2.0.8
  collection: ^1.14.0
  package_info: ^0.4.0
  fluttertoast: 7.1.6
  flutter_staggered_grid_view: ^0.3.0
  adaptive_breakpoints: ^0.0.2
  cupertino_icons: 1.0.0
  http: ^0.12.0+2
  flutter_icons: ^1.0.0
  timeago: 2.0.26
  animations: 1.1.2
  flutter_hooks: ^0.12.0
  share: ^0.6.4+3
  shimmer: 1.1.1
  crypto: 3.0.0
  url_launcher: 5.5.0
  uni_links: 0.4.0
  flutter_html: 1.2.0
  shared_preferences: ^0.5.8
  state_notifier: ^0.5.0
  flutter_secure_storage: 3.3.3
  flutter_slidable: "^0.5.5"
  hive: ^1.4.1+1
  pull_to_refresh: 1.6.3
  intl_phone_number_input: ^0.5.0
  dio: 3.0.10
  fish_redux: 0.3.4
  hive_flutter: 0.3.1

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_driver:
    sdk: flutter
  test:
  path:
  args:
  grinder: ^0.8.0
  pedantic: ^1.9.0
  string_scanner: ^1.0.5

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  generate: true

what should I do to fix it? This is the flutter version info:

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/cruise-open% flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.1, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] IntelliJ IDEA Community Edition (version 2020.2)
[✓] VS Code (version 1.54.1)
[✓] Connected device (2 available)

• No issues found!
4 Answers

This happens because the flutter_driver's null-safety migration didn't make it in time.

Even though it's now fixed, it won't be released in stable channel until around early June (or with the next stable channel release).

Meanwhile, we have two solutions:

  1. Use the beta or dev channel to get the fix ASAP.
  2. Use dependency_overrides in your pubspec.yaml to keep using flutter_driver with your Flutter 2 (while staying in stable channel).

I prefer the second choice. So I edit my pubspec.yaml like this:

dependencies:
  # my list of deps...

dev_dependencies:
  flutter_driver:
    sdk: flutter
  test: any
  # my other dev_deps...

# add this section
dependency_overrides:
  convert: ^3.0.0
  crypto: ^3.0.0
# add this section 

This solution worked for me. I can now install flutter_driver.

This is my reference: https://github.com/flutter/flutter/issues/77282

Solved it by changing my sdk constraints in the pubspec.yaml to

environment:
sdk: ">=2.12.0 <3.0.0"

and changed from flutters stable channel to master channel

Add crypto to dependencies and run flutter pub get:

dependencies:
  crypto: ^3.0.0

Use next approach. But be careful, tests might be break. Insert next code in your pubspec.yaml after dependencies section

dependency_overrides:
  crypto: 3.0.0
Related