Repository: flutter
Issue: `extendBodyBehindAppBar: true` causing rebuilds upon hot reload.
Labels: framework,f: material design,has reproducible steps,P2,found in release: 3.10,team-design,triaged-design,found in release: 3.14

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

Today, I spent a good few hours debugging a problem on a very complex screen that I'm developing. I thought it was other things like my injections and dynamic behaviors I still have. But I came to the conclusion that the problem really was the `extendBodyBehindAppBar` as `true`.

After understanding what that was, I decided to research it and found this very old issue that already reported about it, check below:
- https://github.com/flutter/flutter/issues/56226

Now at this point, I've taken a little time to create a reproducible example that might help us understand a few things.

It can be seen here in this minimal reproducible example:

- https://github.com/felipecastrosales/flutter_rebuild_mre/blob/master/lib/main.dart

---

I noticed that this happens only when the `Scaffold` `body` is not constant, but we can't always make it so.


### Expected results

It is expected that we will not have this case of rebuilds, as this disrupts the development experience (all breakpoints are also duplicated).

If a `Builder` is placed on top of `body`, it can be seen that it is also rebuilt.


### Actual results

It is currently called in a duplicate form.

### Code sample

<details><summary>Code sample</summary>

[The reproducible example can be see here.](https://github.com/felipecastrosales/flutter_rebuild_mre/blob/master/lib/main.dart)

```dart
import 'dart:developer';

import 'package:flutter/material.dart';

void main() {
  runApp(const HomeScreen());
}

/// When is not [const], the body is rebuilt twice when has hot reload.
class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    log('HomeScreen build');
    return MaterialApp(
      home: Scaffold(
        extendBodyBehindAppBar: true,
        body: SampleWidget(
          title: 'Hello World'.toUpperCase(),
        ),
      ),
    );
  }
}

/// When is [const], the body is rebuilt once when has hot reload.
class HomeScreen2 extends StatelessWidget {
  const HomeScreen2({super.key});

  @override
  Widget build(BuildContext context) {
    log('HomeScreen2 build');
    return const MaterialApp(
      home: Scaffold(
        extendBodyBehindAppBar: true,
        body: SampleWidget(
          title: 'Hello World',
        ),
      ),
    );
  }
}

/// Simple example of a widget.
class SampleWidget extends StatelessWidget {
  const SampleWidget({
    super.key,
    required this.title,
  });

  final String title;

  @override
  Widget build(BuildContext context) {
    log('SampleWidget build');
    return Container(
      alignment: Alignment.center,
      child: Text(
        title,
        style: Theme.of(context).textTheme.bodyMedium,
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

Twice  |  Once
:-------------------------:|:-------------------------:
![image](https://github.com/flutter/flutter/assets/59374587/716ea836-df1a-43dd-87cc-6e3f70b6d085)  |  ![image](https://github.com/flutter/flutter/assets/59374587/e5aaf1cc-fa38-41ae-9319-72edcf1e82de)

</details>


### Logs

<details><summary>Logs</summary>

A (stranger behaviour)

```console
[log] HomeScreen build
2 [log] SampleWidget build
```

B (as expected)

```console
[log] HomeScreen build
[log] SampleWidget build
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.3.1 22E772610a darwin-arm64, locale en-BR)
    • Flutter version 3.10.6 on channel stable at /Users/felipecastrosales/fvm/versions/3.10.6
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (4 weeks ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/felipecastrosales/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • ANDROID_HOME = /Users/felipecastrosales/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/felipecastrosales/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.12.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • 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 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.74.3)
    • VS Code at /Users/felipecastrosales/Downloads/app/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] Connected device (4 available)
    • M2003J15SC (mobile) • 062d19ed0405      • android-arm64  • Android 11 (API 30)
    • M2003J15SC (mobile) • 192.168.1.16:5555 • android-arm64  • Android 11 (API 30)
    • macOS (desktop)     • macos             • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
    • Chrome (web)        • chrome            • web-javascript • Google Chrome 115.0.5790.170

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>