After switched to branch 'stable' flutter channel

The following is the build issue.

Error: The specified language version is too high. The highest supported language version is 2.8.

output: ../../third_party/dart/third_party/pkg/collection/lib/src/utils.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.8.
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
^
../../third_party/dart/third_party/pkg/collection/lib/src/wrappers.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.8.
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
^
../../third_party/dart/third_party/pkg/collection/lib/src/functions.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.8.
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
^
6

There are 6 best solutions below

3
On

Run flutter clean and then flutter --version command from the terminal:

terminal execution of aforementioned commands

Then, check the flutter version in pubspec.yml (here it is 1.22.5) and change the version to match the one from the terminal.

enter image description here

0
On

Cause

One of your packages in pubspec.yaml is requiring dart version up that you have installed. For example, I face this issue withe analyzer package. In my pubspec

analyzer: ˆ3.3.1

So I ve run

flutter version
Answer
Tools • Dart 2.13.3

But as you can see here version 3.3.1 require Dart Tools 2.14

enter image description here

Solution

Discover which package version in incompatible with your dart

1
On

In my case, I had Flutter and Dart installed seperately

  1. Dart(Flutter) - v2.19.2
  2. Dart - v2.17.6

When I run dart command, it uses 2.Dart, which is outdated I removed by brew uninstall dart, and after restarting terminal, it uses flutter dart instead of dart which is latest version

0
On

In my case, a package needed a mininum Dart version higher than the app's one (it's at the bottom of your pubspec.lock). Solution: downgrade package's version.

0
On

Why?

This happens, because the your specified language version is higher than the one declared in the .dart_tool directory (specifically in the package_config.json file).

Solution

You can either delete the folder manually or let Flutter tools do it for you. Run flutter clean from the terminal or, if using Android Studio, go to Tools -> Flutter -> Flutter Clean.

7
On

I had the same error yesterday and I fixed it.

This error came when you switch the version of flutter from 1.17.5 (stable channel) to 1.20.? (dev channel).

To fix it, just create a new project using the last version installed on your PC and copy & paste all the files.

The problem comes from the pubspec.lock file because of the versions.

So in conclusion, if you changed the version of Flutter, just create another project and copy the necessary files.