flutter版本解决失败

flutter version solving failed

我试图在我刚刚创建的 flutter 项目中执行 pub get 命令,但它开始出现此错误:

D:\flutter\bin\flutter.bat --no-color pub get
Running "flutter pub get" in stock_exchange...                  
Because every version of flutter from sdk depends on meta 1.1.8 which doesn't match any versions, flutter from sdk is forbidden.

So, because stockexchange depends on flutter any from sdk, version solving failed.
pub get failed (1; So, because stockexchange depends on flutter any from sdk, version solving failed.)
Process finished with exit code 1

pubspec.yaml

name: stockexchange
description: A new Flutter application.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:


# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

flutter doctor 结果

D:\AndroidDevelopment\stock_exchange>flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.17763.1039], locale en-IN)
    • Flutter version 1.12.13+hotfix.9 at D:\flutter
    • Framework revision f139b11009 (4 weeks ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at D:\Android\SDK
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = D:\Android\SDK
    • Java binary at: D:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at D:\Program Files\Android\Android Studio
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

颤动分析:-

Because every version of flutter from sdk depends on meta 1.1.8 which doesn't match any versions, flutter from sdk is forbidden.
So, because stockexchange depends on flutter any from sdk, version solving failed.
Running "flutter pub get" in stock_exchange...
pub get failed (1; So, because stockexchange depends on flutter any from sdk, version solving failed.)

我下载了最新的android studio 3.6,flutter和dart插件,flutter sdk。 我不知道如何解决这个问题,有人能帮我吗?

我找到了问题的解决方案,我只需要将环境变量 PUB_HOSTED_URL 的值更改为 https://pub.dev 但这可能取决于您所在的位置,以获得正确的变量值,如果你不知道那么最好的办法就是删除变量并让 flutter 自动决定 URL。