Repository: flutter
Issue: In release mode, Flutter is unable to capture layout exception errors, and the framework displays the message "TransformLayer is constructed with an invalid matrix."
Labels: framework,a: error message,a: release,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.13,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

The sample code is as follows.
```dart
void main(){
 WidgetsFlutterBinding.ensureInitialized();
      FlutterError.onError = (FlutterErrorDetails errorDetails) {
        print('This is an error on the Flutter SDK');
        print(errorDetails.exception);
        print('-----');
        print(errorDetails.stack);
      };
      runApp( TestApp());
}
class TestApp extends StatefulWidget {
   TestApp({Key? key}) : super(key: key);

  @override
  State<TestApp> createState() => _TestAppState();
}

class _TestAppState extends State<TestApp> {
  var a=SizedBox(
    height: 200,
    child: Row(
      children: <Widget>[TextField(),TextField()]
    ),
  );
  var b=Text('data');
 late Widget current=b;
  @override
  Widget build(BuildContext context) {

    return  MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('data'),),
        body: Column(
          children: <Widget>[
            current ,
            TextButton(onPressed: (){
              setState(() {
                if(current==a){
                  current=b;
                }
                else{
                  current=a;
                }
              });
            }, child: Text('change')),
          ],
        ),
      ),
    );
  }
}
```
3,click "add" button
4, flutter crash 
[ERROR:flutter/flow/layers/transform_layer.cc(24)] TransformLayer is constructed with an invalid matrix.
[ERROR:flutter/flow/layers/transform_layer.cc(24)] TransformLayer is constructed with an invalid matrix.

### Expected results

Flutter crash and  FlutterError.onError not working
[ERROR:flutter/flow/layers/transform_layer.cc(24)] TransformLayer is constructed with an invalid matrix.
[ERROR:flutter/flow/layers/transform_layer.cc(24)] TransformLayer is constructed with an invalid matrix.

### Actual results

Flutter crash and  FlutterError.onError not working
[ERROR:flutter/flow/layers/transform_layer.cc(24)] TransformLayer is constructed with an invalid matrix.
[ERROR:flutter/flow/layers/transform_layer.cc(24)] TransformLayer is constructed with an invalid matrix.

### Code sample

void main(){
 WidgetsFlutterBinding.ensureInitialized();
      FlutterError.onError = (FlutterErrorDetails errorDetails) {
        print('This is an error on the Flutter SDK');
        print(errorDetails.exception);
        print('-----');
        print(errorDetails.stack);
      };
      runApp( TestApp());
}
class TestApp extends StatefulWidget {
   TestApp({Key? key}) : super(key: key);

  @override
  State<TestApp> createState() => _TestAppState();
}

class _TestAppState extends State<TestApp> {
  var a=SizedBox(
    height: 200,
    child: Row(
      children: <Widget>[TextField(),TextField()]
    ),
  );
  var b=Text('data');
 late Widget current=b;
  @override
  Widget build(BuildContext context) {

    return  MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('data'),),
        body: Column(
          children: <Widget>[
            current ,
            TextButton(onPressed: (){
              setState(() {
                if(current==a){
                  current=b;
                }
                else{
                  current=a;
                }
              });
            }, child: Text('change')),
          ],
        ),
      ),
    );
  }
}

### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

![image](https://github.com/flutter/flutter/assets/49134865/a0e86b17-a68f-406f-a4bc-dbe5196f1972)


### Flutter Doctor output

 flutter doctor -v
[!] Flutter (Channel stable, 3.10.4, on macOS 13.2.1 22D68 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.10.4 on channel stable at /Users/tian/fvm/versions/3.10.4
    ! Warning: `dart` on your path resolves to /usr/local/Cellar/dart/3.0.2/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/tian/fvm/versions/3.10.4.
      Consider adding /Users/tian/fvm/versions/3.10.4/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 682aa387cf (3 months ago), 2023-06-05 18:04:56 -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
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/tian/Library/Android/sdk
    • Platform android-33, 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.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.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.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 72.1.4
    • Dart plugin version 223.7571.203

[✓] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] VS Code (version 1.55.2)
    • VS Code at /Users/tian/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] Connected device (3 available)
    • iPhone 14 Pro (mobile) • 362380EB-45FA-4EB5-974E-13DF728E8EFC • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)        • macos                                • darwin-x64     • macOS 13.2.1 22D68 darwin-x64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 116.0.5845.140