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

7

5

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.

Gabrila answered 17/5, 2023 at 6:52 Comment(1)
Try running flutter pub get in terminalJarodjarosite
V
1

I had the same problem, what helped me to solve it was:

  • in AS go to Settings > Languages ​​and Frameworks > flutter and set Flutter SDK path to your new version path and apply
  • make sure that Settings > Languages ​​and Frameworks > dart is using the correct version corresponding to your new version of flutter SDK

Note:
I am using Android Studio.
I am using FVM to manage SDK versions
my update was from 3.3.5 to 3.13.2 (Flutter SDK) - (2.18.2 to 3.1.0 (Dart))

I hope it helps someone

Vinosity answered 18/6 at 19:8 Comment(0)
E
5

Just reloading VsCode fixed the issue for me

Edd answered 2/8, 2023 at 13:29 Comment(0)
T
4

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. 😃

Tiffin answered 17/5, 2023 at 13:9 Comment(1)
you save my life, in my case i use fvm for version 3.10.6Diversification
V
1

I had the same problem, what helped me to solve it was:

  • in AS go to Settings > Languages ​​and Frameworks > flutter and set Flutter SDK path to your new version path and apply
  • make sure that Settings > Languages ​​and Frameworks > dart is using the correct version corresponding to your new version of flutter SDK

Note:
I am using Android Studio.
I am using FVM to manage SDK versions
my update was from 3.3.5 to 3.13.2 (Flutter SDK) - (2.18.2 to 3.1.0 (Dart))

I hope it helps someone

Vinosity answered 18/6 at 19:8 Comment(0)
A
0

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

Admetus answered 15/6, 2023 at 6:43 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Rudiger
I
0

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

Change From:

environment:
  sdk: 'existing_version'

To:

environment:
  sdk: '>=3.0.3 <4.0.0' //TODO: Change Version

After this run,

flutter pub get
flutter pub upgrade
Idelson answered 15/6, 2023 at 7:5 Comment(0)
T
0

I’m using FVM to switch from SDK 2.10.5 to 3.24.2, but I get this error:

Future isn't a type. Try correcting the name to match an existing type.

Initially, I tried importing dependencies and updating the SDK environment in pubspec.yaml in VSCode, but nothing worked. Then, I opened the same project in Android Studio Koala (the newer version), and it ran successfully without any code changes.

command I used in Android Studio(already select sdk using fvm):

fvm flutter pub get

and

fvm flutter run

So, I can assume this issue might be caused by the IDE or Flutter/Dart settings in the IDE(both IDEs have the same SDK path and the same versions of Flutter and Dart installed).

Tressietressure answered 8/11 at 3:8 Comment(0)
A
-3

Flutter clean Flutter pub get

I think that will work for You

Arella answered 17/5, 2023 at 7:14 Comment(1)
Doesn't work unfortunelyGabrila

© 2022 - 2024 — McMap. All rights reserved.