[英]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.