Repository: flutter
Issue: Ink splash disappears when the widget tree is changed
Labels: framework,f: material design,has reproducible steps,P2,team-design,triaged-design,found in release: 3.19,found in release: 3.21

### Steps to reproduce

Using the provided code sample:

1. Run `flutter run`
2. Click the button 
3. Obverse that the ink stop rendering immediately after click

### Expected results

I expected the ink animation to complete normally

### Actual results

The animation ends immediately after the click (after the widget tree is changed)

### Code sample

<details><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() => runApp(const MaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  static final GlobalKey globalKey = GlobalKey();
  var placeInSizedBox = false;

  @override
  Widget build(BuildContext context) {
    Widget content = OutlinedButton(
      key: globalKey,
      onPressed: onButtonPressed,
      child: const Text("Demo button"),
    );

    if (placeInSizedBox) {
      content = SizedBox(child: content);
    }

    return Scaffold(
      body: Center(
        child: content,
      ),
    );
  }

  void onButtonPressed() {
    setState(() {
      placeInSizedBox = !placeInSizedBox;
    });
  }
}

```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

![bug](https://github.com/flutter/flutter/assets/49272216/470c767c-42de-482a-8740-96a7bac52acc)

</details>


### Logs

<details><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[√] Flutter (Channel stable, 3.16.7, on Microsoft Windows [Version 10.0.19045.4170], locale ru-RU)                        
    • Flutter version 3.16.7 on channel stable at C:\Users\Qwin\fvm\versions\3.16.7                                       
    • Upstream repository git@github.com:flutter/flutter.git                                                                                                 
    • Framework revision b390c5c1f5 (1 year, 4 months ago), 2022-12-08 11:42:37 +0300                                                                        
    • Engine revision 4a585b7929                                                                                                                             
    • Dart version 3.2.4                                                                                                                                     
    • DevTools version 2.28.5                                                                                                                                
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
                                                                                                                                                             
[√] Windows Version (Installed version of Windows is version 10 or higher)                                                                                   

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\Qwin\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:\Program Files\Android Studio 2023.1.1.8\jbr\bin\java    
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.6)   
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community   
    • Visual Studio Community 2022 version 17.8.34525.116
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2022.3)
    • Android Studio at C:\Program Files\Android Studio 2022.3.1
    • 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-b2043.56-10027231)

[√] Android Studio (version 2023.1)
    • Android Studio at C:\Program Files\Android Studio 2023.1.1.8
    • 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.7+0-b2043.56-10550314)

[√] VS Code, 64-bit edition (version 1.87.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.84.0

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.19045.4170]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 122.0.6261.129
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 122.0.2365.92

[√] Network resources
    • All expected network resources are available.

```

</details>