Repository: flutter
Issue: Hiding SystemUiOverlay.top on android changes MediaQuery.size.height
Labels: platform-android,framework,f: material design,a: layout,has reproducible steps,P3,found in release: 2.6,team-android,triaged-android

<!-- 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

<!-- You must include full steps to reproduce so that we can reproduce the problem. -->

1. Run `flutter create bug`.
2. Update the files as follows: ... <!-- include every file that is different from the template app! -->
3. ... <!-- describe how to reproduce the problem -->

```
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: SystemStatusBarPage(),
    );
  }
}

class SystemStatusBarPage extends StatefulWidget {
  const SystemStatusBarPage({Key? key}) : super(key: key);

  @override
  State<SystemStatusBarPage> createState() => _SystemStatusBarPageState();
}

class _SystemStatusBarPageState extends State<SystemStatusBarPage> with TickerProviderStateMixin{
  bool statusVisible = false;

  Size? prevSize;
  Size? curSize;

  @override
  Widget build(BuildContext context) {
    final mediaQuery = MediaQuery.of(context);
    if(prevSize == null) {
      prevSize = mediaQuery.size;
    } else if(prevSize != mediaQuery.size){
      curSize ??= mediaQuery.size;
    }
    print('height: ${mediaQuery.size.height}');
    return MediaQuery(
      data: mediaQuery.copyWith(padding: mediaQuery.padding.copyWith(top: 24)),
      child: Scaffold(
        appBar: AppBar(),
        floatingActionButton: IconButton(icon: Icon(Icons.ac_unit), onPressed: () {
          if(statusVisible) {
            SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values.toList()..remove(SystemUiOverlay.top));
          } else {
            SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
          }
          setState(() =>statusVisible = !statusVisible);
        },),
        body: Stack(children: [
          Positioned(top: 0, left: 0, width: 100, child: Container(
            height: (curSize?.height ?? 0)*0.5,
            color: Colors.green,
          )),
          Positioned(
              top: 0,
              left: 110,
              width: 100,
              child: Container(
            height: (prevSize?.height ?? 0)*0.5,
            color: Colors.green,
          )),
        ]),
      ),
    );
  }
}
```
Run app on android device or emulator (I have used Pixel XL API 30 on Android 11.0 emulator and my pixel XL phone)
Click floating icon button 3 times
**Expected results:** <!-- what did you want to see? -->
- Green columns have the same height.
- printed height is identical
**Actual results:** <!-- what did you see? -->
- Green columns (both based on MediaQuery.size.height) are different sizes
I/flutter ( 5825): height: 731.4285714285714
I/flutter ( 5825): height: 731.4285714285714
I/flutter ( 5825): height: 731.4285714285714
I/flutter ( 5825): height: 683.4285714285714
I/flutter ( 5825): height: 683.4285714285714
I/flutter ( 5825): height: 731.4285714285714
I/flutter ( 5825): height: 731.4285714285714
I/flutter ( 5825): height: 683.4285714285714
<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-arm, locale en-NZ)
    • Flutter version 2.5.0 at /Users/user/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cc385b4b8 (9 days ago), 2021-09-07 23:01:49 -0700
    • Engine revision f0826da7ef
    • Dart version 2.14.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/loganwarner/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] 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 2020.3)
    • Android Studio at /Applications/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.10+0-b96-7281165)

[✓] Connected device (3 available)
    • sdk gphone arm64 (mobile)  • emulator-5554                        • android-arm64  • Android 11 (API 30) (emulator)
    • iPhone 12 Pro Max (mobile) • 52A31433-1540-434B-A44C-3F4E46F13691 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 93.0.4577.82

• No issues found!

```

</details>