0

Recently I tried to graft some code acquired online into a local Flutter project.

But the IDE (Android Studio) was underlining various parts of it in red like so:

enter image description here

More detail about the errors:

enter image description here

enter image description here

I tried editting pubspec.yaml but couldn't find where or how to do what it is suggesting.

I'm currenly assuming that the reason this code is underlined like that is because it is written in a more recent version of Dart than what I have installed. Let me know if that is wrong so I can edit/delete this question.

I tried researching the changelog for the Dart language features but could not get meaningful results.

The version of Dart I have installed (the Dart plugin version) is 201.9335.

enter image description here

How can I upgrade this to the latest version of Dart?

I tried right clicking it, but the was no context menu let alone any upgrade option.

There is no upgrade option I can see within Android Studio, only the option to uninstall it.

I also tried going to the Dart plugin homepage and downloading the latest version, then choosing the downloaded jar file to install using Android Studio, but it seemed to just do nothing -- no error -- no success -- no change.

How do you upgrade the Dart plugin in Android Studio to the latest version?

1
  • Have you installed dart locally in your system ? Commented Mar 12, 2021 at 5:33

2 Answers 2

1

If you done all this processes you should have latest dart SDK installed on your machine as well as Android Studio.

The actual problem accrues due to dart version specified in your pubspec.yaml file.

In pubspec.yaml file there is a code like this:

environment:
  sdk: ">=2.7.0 <3.0.0"

This lines of code specifies the Min. and Max. limitation for dart version.

Try this:

environment:
  sdk: ">=2.10.0 <3.0.0" 

If this works let me know about it, Thanks!

Sign up to request clarification or add additional context in comments.

1 Comment

it didn't "work" -- made no difference to this particular issue. I have editted the question.
0

kishans answer is basically correct, but in my particular case, I had to change the min/max to:

environment:
  sdk: ">=2.12.0 <3.0.0"

as was suggested by one of the hints given by Android Studio in my original question.

This solved the errors for this new file, but interestingly, this means all the other (older) files in my project are now underlined in red, though.

So apparently there was some significant change made between 2.11 and 2.12.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.