Repository: flutter
Issue: Upperbound version restrictions for Flutter SDK are ignored  
Labels: tool,d: api docs,P2,team-tool,triaged-tool

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- Please tell us exactly how to reproduce the problem you are running into. -->

1. Specify a build environment for `flutter` with an upperbound version restriction in the project's `pubspec.yaml`.
```
environment:
  sdk: ">=2.13.0 <3.0.0"
  flutter: ">=2.2.0 <2.3.0"
```
2. Run `flutter pub get` to reload the `pubspec.yaml` using Flutter 2.2.2.
3. In `pubspec.lock` the upperbound version is now recorded differently:
```
sdks:
  dart: ">=2.13.0 <3.0.0"
  flutter: ">=2.2.0"
```
4. Now, when upgrading Flutter to version 2.5.1 (stable) and running `flutter pub get` again, no error message is visible that the build environment does not match.

## Logs

<details>
<summary>Logs</summary>

<!--
      Include the full logs of the commands you are running between the lines
      with the backticks below. If you are running any "flutter" commands,
      please include the output of running them with "--verbose"; for example,
      the output of running "flutter --verbose create foo".
-->

```
$ flutter pub get
Downloading Dart SDK from Flutter engine 91c9fc8fe011352879e3bb6660966eafc0847233...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  199M  100  199M    0     0  20.9M      0  0:00:09  0:00:09 --:--:-- 28.8M
Building flutter tool...
  ╔════════════════════════════════════════════════════════════════════════════╗
  ║ A new version of Flutter is available!                                     ║
  ║                                                                            ║
  ║ To update to the latest version, run "flutter upgrade".                    ║
  ╚════════════════════════════════════════════════════════════════════════════╝


Downloading package sky_engine...                                  355ms
Downloading flutter_patched_sdk tools...                           249ms
Downloading flutter_patched_sdk_product tools...                   223ms
Downloading linux-x64 tools...                                   1,183ms
Downloading linux-x64/font-subset tools...                         149ms
Running "flutter pub get" in project...                       1,121ms
$ flutter upgrade
Upgrading Flutter to 2.5.1 from 2.2.2 in /home/ivar/Android/flutter...
Downloading Dart SDK from Flutter engine b3af521a050e6ef076778bcaf16e27b2521df8f8...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  2  221M    2 5518k    0     0  10.1M      0  0:00:21 --:--:--  0:00:21 10.1M
 14  221M   14 31.4M    0     0  20.5M      0  0:00:10  0:00:01  0:00:09 20.5M
 26  221M   26 58.3M    0     0  23.0M      0  0:00:09  0:00:02  0:00:07 23.0M
 38  221M   38 84.6M    0     0  23.9M      0  0:00:09  0:00:03  0:00:06 23.9M
 50  221M   50  111M    0     0  24.5M      0  0:00:09  0:00:04  0:00:05 24.5M
 60  221M   60  133M    0     0  24.1M      0  0:00:09  0:00:05  0:00:04 25.6M
 72  221M   72  159M    0     0  24.4M      0  0:00:09  0:00:06  0:00:03 25.6M
 83  221M   83  184M    0     0  24.4M      0  0:00:09  0:00:07  0:00:02 25.2M
 93  221M   93  205M    0     0  23.8M      0  0:00:09  0:00:08  0:00:01 23.7M
100  221M  100  221M    0     0  24.0M      0  0:00:09  0:00:09 --:--:-- 23.5M
Building flutter tool...

Upgrading engine...
Downloading package sky_engine...                                  376ms
Downloading flutter_patched_sdk tools...                           297ms
Downloading flutter_patched_sdk_product tools...                   248ms
Downloading linux-x64 tools...                                   1,274ms
Downloading linux-x64/font-subset tools...                         351ms

Flutter 2.5.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ffb2ecea52 (9 days ago) • 2021-09-17 15:26:33 -0400
Engine • revision b3af521a05
Tools • Dart 2.14.2

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.1, on Ubuntu 20.04.3 LTS 5.4.0-81-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.1)
[✓] Connected device (1 available)

• No issues found!
$ flutter pub get
Running "flutter pub get" in project...                       1,808ms
The plugins `flutter_jailbreak_detection, flutter_privacy_screen` use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a
future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
```

<!-- If possible, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 2.2.2, on Linux, locale en_US.UTF-8)
    • Flutter version 2.2.2 at /home/ivar/Android/flutter
    • Framework revision d79295af24 (4 months ago), 2021-06-11 08:56:01 -0700
    • Engine revision 91c9fc8fe0
    • Dart version 2.13.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /home/ivar/Android/Sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /home/ivar/Android/Sdk
    • Java binary at: /snap/android-studio/101/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /snap/android-studio/101/android-studio
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
    • IntelliJ at /snap/intellij-idea-ultimate/311
    • Flutter plugin version 60.1.4
    • Dart plugin version 212.4746.57

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1)
    • IntelliJ at /snap/intellij-idea-ultimate/289
    • Flutter plugin version 55.0.5
    • Dart plugin version 211.6693.108

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.61

• No issues found!
```

</details>