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

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  1. 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.
  2. 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'.
  3. 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

无效尝试

常见但无效的做法:

  1. 70% 失败

    Older versions may have the same SDK constraint or introduce other incompatibilities.

  2. 95% 失败

    pubspec.lock is auto-generated and will be overwritten on next 'pub get'.

  3. 90% 失败

    This doesn't upgrade the actual Dart SDK; the local SDK remains at 3.4.0.