Flutter 升级到 3.10 后出现了 “Future isn’t a type” 的问题。

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

Flutter, after upgrading to 3.10, "Future isn't a type"

问题

After upgrading flutter with flutter upgrade to 3.10

All my (previously working) Futures stopped working. Every single future is underlined with red saying "Future isn't a type".

What can I do to fix this? Clearly Future hasn't been removed.

英文:

After upgrading flutter with flutter upgrade to 3.10

All my (previously working) Futures stopped working. Every single future is underlined with red saying "Future isn't a type".

What can I do to fix this? Clearly Future hasn't been removed.

答案1

得分: 3

这也发生在我身上,升级到3.10后。

我正在使用VS Code。在用Android Studio打开后,我能够顺利构建它。

回到VS Code,它又开始正常工作了。 😊

英文:

This was happing to me too after upgrade to 3.10.

I am using VS Code. After opening with Android Studio, I was able to build it without any problem.

Going back to VS Code, and it starts to work again. 😃

答案2

得分: 1

只重新加载 VsCode 对我解决了问题。

英文:

Just reloading VsCode fixed the issue for me

答案3

得分: 0

add "import 'dart:async';" in your code and change "future" to "FutureOr"

英文:

add "import 'dart:async';" in your code and change "future" to "FutureOr"

答案4

得分: 0

一旦升级到 Flutter 3.10,请确保在 pubspec.yaml 文件中更改 Flutter SDK 环境版本。

从:

environment:
  sdk: 'existing_version'

到:

environment:
  sdk: '>=3.0.3 <4.0.0' //TODO: 更改版本

完成后运行:

flutter pub get
flutter pub upgrade
英文:

Once you upgrade to Flutter 3.10, make sure you change the Flutter SDK environment version in pubspec.yaml file

Change From:

environment:
  sdk: &#39;existing_version&#39;

To:

environment:
  sdk: &#39;&gt;=3.0.3 &lt;4.0.0&#39; //TODO: Change Version

After this run,

flutter pub get
flutter pub upgrade

答案5

得分: -2

Flutter clean
Flutter pub get

我认为这对你会有用。

英文:

Flutter clean
Flutter pub get

I think that will work for You

huangapple
  • 本文由 发表于 2023年5月17日 14:52:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76269262.html
匿名

发表评论

匿名网友

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

确定