Repository: flutter
Issue: IntrinsicHeight work incorrect with ConstrainedBox
Labels: framework,f: scrolling,has reproducible steps,P2,found in release: 2.2,found in release: 2.5,team-framework,triaged-framework

IntrinsicHeight incorrectly calculates a child's intrinsic height.

In this case, I expect that content less than scroll viewport and SingleChildScrollView should not scroll.  Because the blue container size should be 200x200.

Maybe that work wrong because RenderConstrainedBox doesn't pass _additionalConstraints to the child, and AspectRatio, on the step of calculating IntrinsicHeight, does not know about ConstrainedBox constraints.

[Original](https://github.com/flutter/flutter/blob/f4abaa0735/packages/flutter/lib/src/rendering/proxy_box.dart#L263):
```dart
  @override
  double computeMaxIntrinsicHeight(double width) {
    if (_additionalConstraints.hasBoundedHeight && _additionalConstraints.hasTightHeight)
      return _additionalConstraints.minHeight;
    final double height = super.computeMaxIntrinsicHeight(width);
    assert(height.isFinite);
    if (!_additionalConstraints.hasInfiniteHeight)
      return _additionalConstraints.constrainHeight(height);
    return height;
  }
```

Maybe this implementation more correct: 
```dart
  @override
  double computeMaxIntrinsicHeight(double width) {
    if (additionalConstraints.hasBoundedHeight &&
        additionalConstraints.hasTightHeight)
      return additionalConstraints.minHeight;
    final double height =
        child!.getMaxIntrinsicHeight(additionalConstraints.maxWidth);
    assert(height.isFinite);
    if (!additionalConstraints.hasInfiniteHeight)
      return additionalConstraints.constrainHeight(height);
    return height;
  }
```


https://user-images.githubusercontent.com/14288495/130261410-a0d929e5-1320-4372-b50d-48547d134363.mov



## Steps to Reproduce


<details> 
<summary>minimal code sample</summary> 

```dart
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

/// This is the main application widget.
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: _title,
      home: MyStatelessWidget(),
    );
  }
}

/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
  const MyStatelessWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: LayoutBuilder(
        builder: (BuildContext context, BoxConstraints viewportConstraints) {
          return SingleChildScrollView(
            child: ConstrainedBox(
              constraints: BoxConstraints(
                minHeight: viewportConstraints.maxHeight,
              ),
              child: IntrinsicHeight(
                child: Column(
                  children: <Widget>[
                    ConstrainedBox(
                      constraints: BoxConstraints(
                        maxWidth: 200,
                      ),
                      child: AspectRatio(
                        aspectRatio: 1,
                        child: Container(
                          color: const Color(0xff0062f5), // Red
                          alignment: Alignment.center,
                          child: const Text('AspectRatio Content'),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          );
        },
      ),
    );
  }
}
``` 

</details>

<details>
  <summary>Logs</summary>

```console
boriskarabanov@MacBook-Pro-Boris clubslane % flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale ru-RU)
    • Flutter version 2.2.3 at /Users/boriskarabanov/dev/sdk/flutter
    • Framework revision f4abaa0735 (7 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at /Users/boriskarabanov/Library/Android/sdk
    • Platform android-30, build-tools 30.0.1
    • ANDROID_HOME = /Users/boriskarabanov/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/boriskarabanov/Library/Android/sdk
    • Java binary at: /Users/boriskarabanov/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Users/boriskarabanov/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
    • IntelliJ at /Users/boriskarabanov/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 59.0.4
    • Dart plugin version 212.4746.57

[✓] VS Code (version 1.59.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.23.0

[✓] Connected device (3 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • sdk gphone x86 arm (mobile)        • emulator-5556 • android-x86    • Android 11 (API 30) (emulator)
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 92.0.4515.159

! Doctor found issues in 1 category.

```

</details>