[英]Update Dart SDK from 2.10.3 to 2.12.0 in Vscode
當我嘗試在 flutter 中更新環境 sdk 時出現以下錯誤。
當前Dart SDK版本是2.10.3。
因為my_app要求SDK version >=2.12.0 <3.0.0,導致版本解析失敗。 pub get failed (1; 因為my_app要求SDK version >=2.12.0 <3.0.0, version solving failed.) exit code 1
flutter doctor -v
給我以下結果
[✓] Flutter (Channel beta, 2.2.0, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-IN)
• Flutter version 2.2.0 at /Users/mustafazaki/flutter
• Framework revision b22742018b (4 weeks ago), 2021-05-14 19:12:57 -0700
• Engine revision a9d88a4d18
• Dart version 2.13.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/mustafazaki/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.1, Build version 12A7403
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.56.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.23.0
[✓] Connected device (3 available)
• iPhone 12 Pro Max (mobile) • 67F57BF6-B6BC-4061-9BFD-01D38275C4E1 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-14-1 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome
91.0.4472.77
• No issues found!
還有,為什么我在vscode上看不到最新的dart更新? 它只顯示 2.10.3
flutter clean
似乎也不起作用。
您可能只需要在其 pubspec.yaml 文件中修改 Flutter 應用程序的目標 Dart 環境。 將環境部分更新為:
environment:
sdk: ">=2.10.0 <3.0.0"
早在 2021 年的 Dart SDK 變更日志中就提到了它。另外,如果flutter upgrade
不起作用。 嘗試在命令中添加--force
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.