Repository: flutter
Issue: Wrong tween with Hero.createRectTween when using different child sizes for source and destination routes
Labels: framework,a: animation,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.13,found in release: 3.16

### 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

I have a profile photo thumbnail in my app that, when tapped, shows the profile photo in fullscreen size. I want to animate between the thumbnail and fullscreen using the `Hero` widget, using a plain linear `RectTween`.

This works on the transition to fullscreen, but not on the transition back out again, when the Back button is pressed. The tween into fullscreen works correctly, but on the way out, the image suddenly jumps to about 80% of the size, and then proceeds to follow a strange curved tween path, which is not the same as the linear path followed on the way in. You can observe this (slowed down) in the video attached below.

I tried specifying the same `createRectTween` in both `Hero` widgets (because I assume that one is for the forward direction and the other is for the reverse direction) -- see the code sample below -- but that did not help.

### Expected results

The tween should work the same way forwards and backwards.

### Actual results

The forwards direction respects the provided `createRectTween` function in the `Hero`, but the reverse direction does not.

### Code sample

<details><summary>Code sample</summary>

This is the thumbnail `Hero`:

```dart
            child: Hero(
              tag: heroTag,
              createRectTween: (begin, end) =>
                  RectTween(begin: begin, end: end),
              child: borderRadius == null
                  ? image
                  : ClipRRect(
                      borderRadius: BorderRadius.circular(borderRadius!),
                      child: image,
                    ),
            ),
```

This is the fullscreen `Hero`:

```dart
void showFullScreenHeroModal({
  required Widget child,
  required String heroTag,
  Color? stackedBackButtonColor,
}) {
  navigator.push(
    PageRouteBuilder(
      opaque: false,
      pageBuilder: (BuildContext pageContext, _, __) {
        return Scaffold(
          backgroundColor: Colors.transparent,
          body: SafeArea(
            child: Hero(
              tag: heroTag,
              createRectTween: (begin, end) =>
                  RectTween(begin: begin, end: end),
              child: Stack(
                children: [
                  // Content
                  child,
                  // Back button at top left
                  BackButton(color: stackedBackButtonColor),
                ],
              ),
            ),
          ),
        );
      },
    ),
  );
}
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

Animation is slowed down 10x:

https://github.com/flutter/flutter/assets/811305/3aa5284c-38d8-4e16-968f-00c6e31d4c51

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
$ flutter doctor -v
[✓] Flutter (Channel beta, 3.16.0-0.2.pre, on Fedora Linux 38 (Workstation Edition) 6.5.6-200.fc38.x86_64, locale en_US.utf8)
    • Flutter version 3.16.0-0.2.pre on channel beta at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fe6553b689 (5 days ago), 2023-10-11 19:07:11 -0700
    • Engine revision 249cc9b86c
    • Dart version 3.2.0 (build 3.2.0-210.2.beta)
    • DevTools version 2.28.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /home/luke/Android/Sdk
    • Platform android-UpsideDownCake, build-tools 33.0.1
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 16.0.6 (Fedora 16.0.6-3.fc38)
    • cmake version 3.27.7
    • ninja version 1.11.1
    • pkg-config version 1.8.0

[✓] Android Studio (version 2022.2)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 73.0.2
    • Dart plugin version 222.4582
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.83.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.74.0

[✓] Connected device (3 available)
    • sdk gphone x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Linux (desktop)            • linux         • linux-x64      • Fedora Linux 38 (Workstation Edition) 6.5.6-200.fc38.x86_64
    • Chrome (web)               • chrome        • web-javascript • Google Chrome 118.0.5993.70

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>