Repository: flutter
Issue: Specifying `leading` causes Hero transition to break between `CupertinoSliverNavigationBar` and `CupertinoNavigationBar`
Labels: framework,a: animation,f: cupertino,a: quality,has reproducible steps,P2,found in release: 3.0,found in release: 3.1,team-design,triaged-design

## Steps to Reproduce

There is a wonderful Hero transition between `CupertinoSliverNavigationBar` and `CupertinoNavigationBar` that I would love to use. However, due to https://github.com/flutter/flutter/issues/42759, I have to wrap the `CupertinoNavigationBarBackButton` into a `MediaQuery` to avoid jank on the leading element. To do so, I have to specify the `leading` attribute, but as soon as I do so, the Hero transition disappears.

So right now I can **either have the Hero transition and a janky animation, or no Hero transition but a clean animation.**

| Without leading | With leading | 
| -- | -- |
| <video src="https://user-images.githubusercontent.com/18680169/177541621-b82c7bd9-45ab-4798-bcb1-c5439840d1fb.MP4" /> | <video src="https://user-images.githubusercontent.com/18680169/177541555-c9398cc5-de6b-4df6-aa5e-3f0de057cb90.MP4" /> |

<details>
<summary>Code sample</summary>

```dart
import 'package:flutter/cupertino.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(home: FirstPage());
  }
}

class FirstPage extends StatelessWidget {
  const FirstPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      child: CustomScrollView(
        slivers: <Widget>[
          CupertinoSliverNavigationBar(
            largeTitle: MediaQuery(
              data: MediaQueryData(
                textScaleFactor: MediaQuery.textScaleFactorOf(context),
              ),
              child: const Text('First'),
            ),
          ),
          SliverFillRemaining(
            child: Center(
              child: CupertinoButton.filled(
                child: const Text('Go to second'),
                onPressed: () {
                  Navigator.push(
                    context,
                    CupertinoPageRoute<void>(
                      builder: (BuildContext context) => const SecondPage(),
                    ),
                  );
                },
              ),
            ),
          ),
        ],
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  const SecondPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        // THIS IS THE LEADING SECTION OF THE NAVIGATION BAR THAT CAUSES THE HERO TRANSITION TO DISAPPEAR
        leading: MediaQuery(
          data: MediaQueryData(
            textScaleFactor: MediaQuery.textScaleFactorOf(context),
          ),
          child: CupertinoNavigationBarBackButton(
            onPressed: () => Navigator.pop(context),
            previousPageTitle: 'First',
          ),
        ),
        // END OF THE LEADING SECTION
        middle: MediaQuery(
          data: MediaQueryData(
            textScaleFactor: MediaQuery.textScaleFactorOf(context),
          ),
          child: const Text('Second'),
        ),
        padding: EdgeInsetsDirectional.zero,
      ),
      child: const Center(
        child: Text(
          'Second page',
          style: TextStyle(color: CupertinoColors.white),
        ),
      ),
    );
  }
}
```

</details>

<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. If there is a crash, please include
      the entirety of the crash log including the backtrace.
-->

[Logs.txt](https://github.com/flutter/flutter/files/9054448/Logs.txt)

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
Analyzing jankynavbarbug...                                             
No issues found! (ran in 1.8s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 3.0.4, on macOS 12.4 21F79 darwin-x64, locale
    en-DE)
    • Flutter version 3.0.4 at /Users/gitlab/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 85684f9300 (6 days ago), 2022-06-30 13:22:47 -0700
    • Engine revision 6ba2af10bb
    • Dart version 2.17.5
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/gitlab/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.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
      11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.68.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.44.0

[✓] VS Code (version 1.68.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • iPhony (mobile) • 99bd617f9b5cdc55182de37b4dc0717de5a068a9 • ios
      • iOS 15.5 19F77
    • macOS (desktop) • macos                                    • darwin-x64
      • macOS 12.4 21F79 darwin-x64
    • Chrome (web)    • chrome                                   •
      web-javascript • Google Chrome 103.0.5060.114

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

</details>