0

我将颤振更新到最新版本:

PS C:\Users\pc> flutter --version
Flutter 2.0.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8962f6dc68 (8 days ago) • 2021-03-11 13:22:20 -0800
Engine • revision 5d8bf811b3
Tools • Dart 2.12.1

并且毫无问题地运行了颤振医生:

PS C:\Users\pc> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.2, on Microsoft Windows [Version 10.0.19042.867], locale en-GB)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] IntelliJ IDEA Ultimate Edition (version 2020.3)
[√] VS Code (version 1.51.1)
[√] Connected device (3 available)

• No issues found!

所以我创建了一个新的颤振项目,并带来了我知道我会使用的依赖项和包(每个文档后面的最新版本):

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_bloc: ^6.1.3
  moor: ^4.1.0
  sqlite3_flutter_libs: ^0.4.1
  path_provider: ^2.0.1
  path: ^1.8.0
  firebase_messaging: ^9.0.0
  equatable: ^2.0.0
  multi_image_picker: ^4.8.0
  chopper: ^3.0.2


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^1.0.0
  chopper_generator: ^3.0.4
  moor_generator: ^4.1.0

但是当我运行 pub get 时,我遇到了这个问题,它说 chopper_generator 和 moor_generator 不兼容,如何解决这个问题?我怎样才能找到兼容的版本?很难在其文档中找到每个包的更改日志,而且我似乎没有找到有关分析器版本的任何详细信息......我是否需要放弃其中一个包?

Because analyzer_plugin >=0.2.5 <0.4.0 depends on analyzer ^0.39.12 and 
analyzer_plugin >=0.4.0 depends on analyzer ^0.41.0, analyzer_plugin >=0.2.5 
requires analyzer ^0.39.12 or ^0.41.0.
And because chopper_generator >=3.0.6 depends on analyzer ^0.40.4, 
analyzer_plugin >=0.2.5 is incompatible with chopper_generator >=3.0.6.
And because chopper_generator >=3.0.5 <3.0.6 depends on analyzer ^0.39.8 and 
chopper_generator >=3.0.4 <3.0.5 depends on analyzer ^0.39.0, if 
analyzer_plugin >=0.2.5 and chopper_generator >=3.0.4 then analyzer ^0.39.0.
And because moor_generator >=4.1.0 <4.2.0 depends on analyzer >=0.40.0 
<0.43.0 and moor_generator >=4.0.0-dev <4.2.0 depends on analyzer_plugin 
>=0.3.0 <0.5.0, chopper_generator >=3.0.4 is incompatible with moor_generator 
>=4.1.0 <4.2.0.
And because no versions of moor_generator match >4.2.0 <5.0.0 and 
moor_generator 4.2.0 depends on build_resolvers ^2.0.0, if chopper_generator 
>=3.0.4 and moor_generator ^4.1.0 then build_resolvers ^2.0.0.
And because no versions of build_resolvers match >2.0.0 <3.0.0 and 
build_resolvers 2.0.0 depends on logging ^1.0.0, if chopper_generator >=3.0.4 
and moor_generator ^4.1.0 then logging ^1.0.0.
Because chopper_generator >=3.0.5 depends on logging ^0.11.4 and 
chopper_generator >=0.1.0 <3.0.5 depends on logging ^0.11.0, 
chopper_generator >=0.1.0 requires logging ^0.11.0.
Thus, chopper_generator >=3.0.4 is incompatible with moor_generator ^4.1.0.
So, because fournisseur depends on both chopper_generator ^3.0.4 and 
moor_generator ^4.1.0, version solving failed.
pub get failed (1; So, because fournisseur depends on both chopper_generator 
^3.0.4 and moor_generator ^4.1.0, version solving failed.)
Process finished with exit code 1
4

2 回答 2

0

在使用flutter几个月后,我找到了一个更好的解决方案,并解决了flutter中的依赖冲突。我让 pubspec 通过将冲突依赖项的版本设置为any. 例如:

chopper_generator: any
hive_generator: any

在获得依赖项后,我检查pubspec.lock使用的版本,然后用在文件any中找到的选定版本覆盖。.lock

注意:我将另一个答案保留为已接受,因为当时(几个月前)它对我有所帮助。

于 2021-12-01T12:30:42.773 回答
0

一种可能的解决方案是降低其中一个库的版本,直到它们相互兼容。

于 2021-03-19T18:51:13.610 回答