Repository: flutter
Issue: Transform is not properly applied with widget which has wrapped with RepaintBoundary
Labels: framework,has reproducible steps,P2,found in release: 3.10,found in release: 3.12,team-framework,triaged-framework

### 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've encountered a problem which is an unexpected behavior when the transform is wrapped with the `RepaintBoundary`, see the video below.

[](https://github.com/flutter/flutter/assets/39793325/9bee951d-7bdf-44dc-be76-4d1c7c1fae18)

I've done the test on flutter web(wasm/html) and macOS native, and I got this result table:
<img width="622" alt="image" src="https://github.com/flutter/flutter/assets/39793325/82ea5a01-1254-4b11-9af2-6aadca9539ba">

idk which is the expected behavior, but they should show the same rendering result on the platform whatever I choose.

1. git clone this repo: https://github.com/Kingtous/dora_demo
2. flutter run 

I've reproduced with Flutter 3.0.5, 3.3.0, and 3.10.3.

### Expected results

`RepaintBoundary` should not influence the rendering.

### Actual results

`RepaintBoundary` causes the transform performs incorrectly.

### Code sample

<details><summary>Code sample</summary>

Reproduce demo: https://github.com/Kingtous/dora_demo

```dart
import 'dart:math';
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'dart:ui' as ui;

void main() {
  runApp(App());
}

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Stack(
        children: const [
          Home(),
        ],
      ),
    );
  }
}

class Home extends StatefulWidget {
  const Home({super.key});

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  var rotateX = 0.0;
  var value = 0.5;
  final key = GlobalKey<State>();
  var flipRateScale = 2.0;
  Uint8List? img;

  @override
  Widget build(BuildContext context) {
    var transform = Matrix4.identity()..setEntry(3, 2, 0.001);
    // print(transform);
    return Scaffold(
      body: Row(
        children: [
          Expanded(
              child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(32.0),
                child: Column(
                  children: [
                    const Text("With RepaintBoundary"),
                    Transform(
                      transform: transform.clone()
                        ..rotateX(-value * flipRateScale),
                      child: Container(
                        color: Colors.red,
                        width: 150,
                        height: 150,
                        alignment: Alignment.center,
                        child: RepaintBoundary(
                          key: key,
                          child: Transform(
                            // key: key,
                            transform: transform.clone()
                              ..rotateY(-value * flipRateScale),
                            child: Container(
                              color: Colors.black,
                              width: 60,
                              height: 60,
                            ),
                          ),
                        ),
                      ),
                    ),
                    // Material(
                    //   child: Container(
                    //     child: Text("${transform}"),
                    //   ),
                    // ),

                    // Material(
                    //   child: Transform(
                    //     transform: Matrix4.skewX(0.1)..rotateX(rotateX),
                    //     child: ColoredBox(
                    //       color: Colors.black,
                    //       child: Transform(
                    //         alignment: Alignment.topRight,
                    //         transform: Matrix4.skewX(0.1)..rotateX(rotateX),
                    //         child: Container(
                    //           padding: const EdgeInsets.all(8.0),
                    //           color: const Color(0xFFE8581C),
                    //           child: const Text('测试！'),
                    //         ),
                    //       ),
                    //     ),
                    //   ),
                    // ),
                    const SizedBox(
                      height: 8.0,
                    ),
                    Material(
                      child: SizedBox(
                        width: 100,
                        height: 10,
                        child: Slider(
                            value: value,
                            onChanged: (v) {
                              setState(() {
                                rotateX = 2 * pi * v;
                                value = v;
                              });
                              Future.delayed(Duration.zero, () {
                                final bound =
                                    key.currentContext?.findRenderObject()
                                        as RenderRepaintBoundary;
                                bound.toImage().then((value) async {
                                  final img = await value.toByteData(
                                      format: ui.ImageByteFormat.png);
                                  setState(() {
                                    this.img = img?.buffer.asUint8List();
                                  });
                                });
                              });
                            }),
                      ),
                    ),
                    const SizedBox(
                      height: 8.0,
                    ),

                    Column(
                      children: [
                        TextButton(
                            onPressed: () {
                              final bound = key.currentContext
                                  ?.findRenderObject() as RenderRepaintBoundary;
                              bound.toImage().then((value) async {
                                final img = await value.toByteData(
                                    format: ui.ImageByteFormat.png);
                                setState(() {
                                  this.img = img?.buffer.asUint8List();
                                });
                              });
                            },
                            child: const Text("Catch Images")),
                        img == null
                            ? Text("img")
                            : Image.memory(
                                img!,
                                width: 100,
                                height: 100,
                                fit: BoxFit.contain,
                              )
                      ],
                    )
                  ],
                ),
              )
            ],
          )),
          Expanded(
              child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(32.0),
                child: Column(
                  children: [
                    const Text("Without RepaintBoundary"),
                    Transform(
                      transform: transform.clone()
                        ..rotateX(-value * flipRateScale),
                      child: Container(
                        color: Colors.red,
                        width: 150,
                        height: 150,
                        alignment: Alignment.center,
                        child: Transform(
                          // key: key,
                          transform: transform.clone()
                            ..rotateY(-value * flipRateScale),
                          child: Container(
                            color: Colors.black,
                            width: 60,
                            height: 60,
                          ),
                        ),
                      ),
                    ),
                    // Material(
                    //   child: Container(
                    //     child: Text("${transform}"),
                    //   ),
                    // ),

                    // Material(
                    //   child: Transform(
                    //     transform: Matrix4.skewX(0.1)..rotateX(rotateX),
                    //     child: ColoredBox(
                    //       color: Colors.black,
                    //       child: Transform(
                    //         alignment: Alignment.topRight,
                    //         transform: Matrix4.skewX(0.1)..rotateX(rotateX),
                    //         child: Container(
                    //           padding: const EdgeInsets.all(8.0),
                    //           color: const Color(0xFFE8581C),
                    //           child: const Text('测试！'),
                    //         ),
                    //       ),
                    //     ),
                    //   ),
                    // ),
                    const SizedBox(
                      height: 8.0,
                    ),
                    Material(
                      child: SizedBox(
                        width: 100,
                        height: 10,
                        child: Slider(
                            value: value,
                            onChanged: (v) {
                              setState(() {
                                rotateX = 2 * pi * v;
                                value = v;
                              });
                              Future.delayed(Duration.zero, () {
                                final bound =
                                    key.currentContext?.findRenderObject()
                                        as RenderRepaintBoundary;
                                bound.toImage().then((value) async {
                                  final img = await value.toByteData(
                                      format: ui.ImageByteFormat.png);
                                  setState(() {
                                    this.img = img?.buffer.asUint8List();
                                  });
                                });
                              });
                            }),
                      ),
                    ),
                    const SizedBox(
                      height: 8.0,
                    ),

                    Column(
                      children: [
                        TextButton(
                            onPressed: () {
                              final bound = key.currentContext
                                  ?.findRenderObject() as RenderRepaintBoundary;
                              bound.toImage().then((value) async {
                                final img = await value.toByteData(
                                    format: ui.ImageByteFormat.png);
                                setState(() {
                                  this.img = img?.buffer.asUint8List();
                                });
                              });
                            },
                            child: const Text("Catch Images")),
                        img == null
                            ? Text("img")
                            : Image.memory(
                                img!,
                                width: 100,
                                height: 100,
                                fit: BoxFit.contain,
                              )
                      ],
                    )
                  ],
                ),
              )
            ],
          ))
        ],
      ),
    );
  }
}

```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

[](https://github.com/flutter/flutter/assets/39793325/9bee951d-7bdf-44dc-be76-4d1c7c1fae18)

</details>


### Logs

<details><summary>Logs</summary>

```console
None
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.10.3, on macOS 13.4 22F66 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.10.3 on channel stable at /Users/kingtous/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f92f44110e (6 days ago), 2023-06-01 18:17:33 -0500
    • Engine revision 2a3401c9bb
    • Dart version 3.0.3
    • DevTools version 2.23.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/kingtous/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /usr/local/opt/openjdk@11/bin/java
    • Java version OpenJDK Runtime Environment Homebrew (build 11.0.19+0)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio
    • Android Studio at /Users/kingtous/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9526055/Android Studio Preview.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
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.66.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.4 22F66 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 114.0.5735.106

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
```

</details>