flutter
build_error
ai_generated
true
当前Dart SDK版本不满足约束:因为your_project依赖于package_a ^2.0.0,该包需要SDK版本>=3.5.0 <4.0.0,但当前SDK为3.4.0
The current Dart SDK version does not satisfy the constraint: because your_project depends on package_a ^2.0.0 which requires SDK version >=3.5.0 <4.0.0, but your current SDK is 3.4.0
ID: flutter/sdk-constraint-violation
85%修复率
85%置信度
1证据数
2024-06-01首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Flutter 3.22 | active | — | — | — |
| Dart 3.4.0 | active | — | — | — |
| Dart 3.5.0 | active | — | — | — |
根因分析
某个依赖项需要的Dart SDK版本高于项目pubspec.yaml中配置的或本地安装的版本。
English
A dependency requires a higher Dart SDK version than the one configured in the project's pubspec.yaml or installed locally.
解决方案
-
Upgrade the Dart SDK: run 'flutter upgrade' to get the latest Flutter which includes a higher Dart SDK, or download a newer Dart SDK manually and update the PATH.
-
Downgrade the problematic package to a version that supports your current SDK. Check pub.dev for older versions and update pubspec.yaml: 'package_a: ^1.9.0'.
-
Use dependency_overrides in pubspec.yaml to force a version that works, but be aware of potential issues: dependency_overrides: package_a: ^1.9.0
无效尝试
常见但无效的做法:
-
70% 失败
Older versions may have the same SDK constraint or introduce other incompatibilities.
-
95% 失败
pubspec.lock is auto-generated and will be overwritten on next 'pub get'.
-
90% 失败
This doesn't upgrade the actual Dart SDK; the local SDK remains at 3.4.0.