如何在现有的Flutter项目中更新Dart版本?

huangapple go评论58阅读模式
英文:

How can I update dart version in existing flutter project?

问题

以下是翻译好的部分:

当我想要将“flutter_iconpicker”包添加到我的当前Flutter项目中时,它会出现下面的错误。我已经更新了我的计算机上的Flutter和Dart版本,但没有成功。

当前Dart SDK版本为2.18.1。

因为sample_project依赖于flutter_iconpicker >=3.2.3,它要求SDK版本 >=3.0.0 <4.0.0,版本解决失败。
pub get失败(1;因为sample_project依赖于flutter_iconpicker >=3.2.3,它要求SDK版本 >=3.0.0 <4.0.0,版本解决失败。)

flutter --version输出:

Flutter 3.10.4 • 稳定渠道 • https://github.com/flutter/flutter.git
Framework • 版本 682aa387cf(7天前) • 2023-06-05 18:04:56 -0500
引擎 • 版本 2a3401c9bb
工具 • Dart 3.0.3 • DevTools 2.23.1

关于pubspec.yaml的代码如下:

environment:
sdk: '>=2.18.1 <3.0.0'

dependencies:
flutter:
sdk: flutter

cupertino_icons: ^1.0.2
google_fonts: ^4.0.4
flutter_svg: ^1.1.3
flutter_staggered_grid_view: ^0.6.2
url_launcher: ^6.1.10
visibility_detector: ^0.4.0+2
provider: ^6.0.5
firebase_core: ^2.13.1
cloud_firestore: ^4.8.0
flutter_iconpicker: ^3.2.4

感谢到目前为止回复的所有人。

英文:

When I want to add the "flutter_iconpicker" package to my current flutter project, it gives the error in question below. I updated the flutter and dart versions on my computer but that didn't work.

The current Dart SDK version is 2.18.1.

Because sample_project depends on flutter_iconpicker &gt;=3.2.3 which requires SDK version &gt;=3.0.0 &lt;4.0.0, version solving failed.
pub get failed (1; Because sample_project depends on flutter_iconpicker &gt;=3.2.3 which requires SDK version &gt;=3.0.0 &lt;4.0.0, version solving failed.)

flutter --version output:

Flutter 3.10.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 682aa387cf (7 days ago) • 2023-06-05 18:04:56 -0500
Engine • revision 2a3401c9bb
Tools • Dart 3.0.3 • DevTools 2.23.1

The pubspec.yaml code on the subject is below.

environment:
  sdk: &#39;&gt;=2.18.1 &lt;3.0.0&#39;

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  google_fonts: ^4.0.4
  flutter_svg: ^1.1.3
  flutter_staggered_grid_view: ^0.6.2
  url_launcher: ^6.1.10
  visibility_detector: ^0.4.0+2
  provider: ^6.0.5
  firebase_core: ^2.13.1
  cloud_firestore: ^4.8.0
  flutter_iconpicker: ^3.2.4

Thanks to everyone who has responded so far.

答案1

得分: 0

我在Android Studio中遇到了问题。我注意到,当我尝试在Vs Code或终端中运行它时,我没有收到错误。后来我注意到我的Dart SDK路径 "Android Studio > 设置 > 语言 > Dart > Dart SDK路径" 与旧版本相关联。我通过在这里更改路径为当前的SDK路径来解决了我的问题。

感谢所有回复的人。

英文:

I was getting the issue in Android Studio. I noticed that when I try to run it with Vs Code or via terminal, I don't get an error. Later I noticed that my dart sdk path "Android Studio>Settinigs>Languages>Dart>Dart Sdk Path" was linked to an old version. I solved my problem by changing the path here with the current sdk path.

Thanks to everyone who replied.

huangapple
  • 本文由 发表于 2023年6月13日 00:50:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76458758.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定