Updating Flutter SDK Constraints

Last reviewed by Frank Treacy
with Flutter 1.7.8

So you are getting the “Try updating the SDK constraints” message:

screenshot

Here I am trying to use the collection spread operator, but this Flutter project has to support Dart 2.1.0 through 3.0.0 according to what is specified in my pubspec.yaml:

# pubspec.yaml

# ...

environment:
  sdk: ">=2.1.0 <3.0.0"

As the collection spread operator was introduced in Dart 2.2.2, we need to update the lower boundary:

# pubspec.yaml

# ...

environment:
  sdk: ">=2.2.2 <3.0.0"

(Clicking the “Quick Fix” link in VS Code will do this for us! But it won’t save the file.)

Run flutter pub get and voilà, warning gone!

The best from the Flutter-verse in 3 minutes or less? Join Snacks!

Delivered twice monthly. No link walls. No spam. EVER.

See also