Repository: flutter
Issue: Selection disapears if widget rebuilds in the `ListView `
Labels: framework,f: scrolling,has reproducible steps,P2,f: selection,found in release: 3.7,found in release: 3.10,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

Text selection disappears on rebuild if widgets used in the next order `ListView -> Text.rich -> [TextSpan, WidgetSpan]`. 

Without `WidgetSpan` or with `const WidgetSpan`, selection doesn't disappear. 
Or if use `Column` insted of `ListView` selection doesn't disappear too.

### Expected results

Text selection doesn't disappear

### Actual results

Text selection disappears

### Code sample

<details><summary>Code sample</summary>

I add rebuild when a selection ends to show that selection has literally disapears. (``` onPointerUp: (_) { setState(() {}); }, ```)

```dart

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String text = 'Flutter Demo Home Page';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: SelectionArea(
        child: MyHomePage(title: text),
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  double width = 60;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: ListView(
          children: <Widget>[
            ...[0, 1, 2, 3, 4].map((e) {
              return Listener(
                onPointerUp: (_) {
                  setState(() {});
                },
                child: Text.rich(
                  TextSpan(
                    children: [
                      const TextSpan(text: 'text to selection'),
                      WidgetSpan(
                        child: SizedBox(width: width),
                      ),
                    ],
                  ),
                ),
              );
            }).toList(),
          ],
        ),
      ),
    );
  }
}


```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

https://user-images.githubusercontent.com/71345244/231763436-8e00d1b3-0b64-4ac8-9446-1d05cee19e23.mp4


</details>


### Logs

_No response_

### Flutter Doctor output

<details><summary>Doctor output</summary>

```console

[√] Flutter (Channel stable, 3.7.10, on Microsoft Windows [Version 10.0.22621.1555], locale ru-RU)
    • Flutter version 3.7.10 on channel stable at C:\Users\Andri\Documents\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4b12645012 (10 days ago), 2023-04-03 17:46:48 -0700
    • Engine revision ec975089ac
    • Dart version 2.19.6
    • DevTools version 2.20.1

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\Andri\AppData\Local\Android\sdk
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.3)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33516.290
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.15+0-b2043.56-9505619)

[√] VS Code (version 1.77.1)
    • VS Code at C:\Users\Andri\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.1555]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 111.0.5563.147
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 111.0.1661.54

[√] HTTP Host Availability
    • All required HTTP hosts are available

```

</details>