3

I have an app (with null-safety), and want to use integration_test package to do some testing. The pubspec.yaml looks like:

dependencies:
  archive: ^3.1.2
  ...

dev_dependencies:
  build_resolvers: ^2.0.0
  build_runner: ^1.11.5
  flutter_test:
    sdk: flutter
  integration_test:
    sdk: flutter
  ...

Then it errors:

Because every version of flutter_driver from sdk depends on archive 2.0.13 and my_app depends on archive ^3.1.2, flutter_driver from sdk is forbidden.

I cannot use the non-null-safety version (2.x) of archive package, because if I do so, my app code will fail to run in null safety mode! I can accept that my tests run in non-null-safety mode, but I cannot tolerate my app code run in non-null-safety mode.

Thanks for any suggestions!

ch271828n
  • 15,854
  • 5
  • 53
  • 88
  • 1
    You need to override the archive version. Have a look at https://stackoverflow.com/questions/23031384/how-to-specify-dependency-overrides-in-pubspec-yaml . I'm also not sure why the flutter_driver is depending on an old version of archive. Are using the latest flutter sdk version? – CoderUni May 13 '21 at 06:27
  • @Uni imho because flutter driver is not null safe? – ch271828n May 13 '21 at 06:38
  • @Uni on the other hand, dependency_overrides is quite unsafe :( can I use it without any fear? – ch271828n May 13 '21 at 06:38
  • @Uni I (possibly) solved this problem using dependency_overrides. Not sure whether there will be hidden issues, but looks ok currently. Thank you! – ch271828n May 13 '21 at 07:06
  • 1
    I'm glad it was able to help you. Unfortunately, dependency_override is **generally** unsafe but it is **safe** in your scenario because it is only being used for testing. Errors would only occur during testing and not when the user is using the app. – CoderUni May 17 '21 at 12:46

1 Answers1

3

You need to override the archive package version to tell flutter_driver to use the latest one:

dev_dependencies:
  build_resolvers: ^2.0.0
  build_runner: ^1.11.5
  flutter_test:
    sdk: flutter
  integration_test:
    sdk: flutter
dependency_overrides:
  archive: ">=3.1.2"
CoderUni
  • 5,474
  • 7
  • 26
  • 58