flutter build_error ai_generated true

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

Also available as: JSON · Markdown · 中文
85%Fix Rate
85%Confidence
1Evidence
2024-06-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Flutter 3.22 active
Dart 3.4.0 active
Dart 3.5.0 active

Root Cause

A dependency requires a higher Dart SDK version than the one configured in the project's pubspec.yaml or installed locally.

generic

中文

某个依赖项需要的Dart SDK版本高于项目pubspec.yaml中配置的或本地安装的版本。

Workarounds

  1. 95% success 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.
    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. 80% success 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'.
    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. 75% success 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
    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. 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

Dead Ends

Common approaches that don't work:

  1. 70% fail

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

  2. 95% fail

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

  3. 90% fail

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