Repository: flutter
Issue: Dismissing Dismissibles in a short sequence will only remove some, not all
Labels: framework,f: scrolling,f: gestures,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

1. Create a Listview or Sliver within a stateful widget
2. Add Dismissibles (generated from an array) (there's no difference between using Listview.builder or just a plain array)
3. Add keys to the Dismissibles, obviously required
4. In onDismiss remove the element from the list with a setState
5. Test the app, mobile or desktop, all have the same behavior
6. Remove them as fast as you can (or alternatively remove one and instantaneously drag another one about halfway)

As an alternative you can run the code on the official Dismissible documentation, since the issue is also present there

### Expected results

If you remove them quickly all elements should be dismissed, if you remove one and drag another, the drag state should be kept

### Actual results

Once one element is removed and called its setState, all other elements lose their dismiss state and reset, also the ones you are currently dragging. Because of the keys this only happens if you remove the elements from the top to the bottom, not the other way around

### Code sample

<details><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

/// Flutter code sample for [Dismissible].

void main() => runApp(const DismissibleExampleApp());

class DismissibleExampleApp extends StatelessWidget {
  const DismissibleExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Dismissible Sample')),
        body: const DismissibleExample(),
      ),
    );
  }
}

class DismissibleExample extends StatefulWidget {
  const DismissibleExample({super.key});

  @override
  State<DismissibleExample> createState() => _DismissibleExampleState();
}

class _DismissibleExampleState extends State<DismissibleExample> {
  List<int> items = List<int>.generate(100, (int index) => index);

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: items.length,
      padding: const EdgeInsets.symmetric(vertical: 16),
      itemBuilder: (BuildContext context, int index) {
        return Dismissible(
          background: Container(
            color: Colors.green,
          ),
          key: ValueKey<int>(items[index]),
          onDismissed: (DismissDirection direction) {
            setState(() {
              items.removeAt(index);
            });
          },
          child: ListTile(
            title: Text(
              'Item ${items[index]}',
            ),
          ),
        );
      },
    );
  }
}
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>


https://github.com/flutter/flutter/assets/68563081/57bc3534-1fd2-425d-bae4-22358a532861



</details>


### Logs

<details><summary>Logs</summary>

```console
Logs are not of any relevance
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.7.10, on Fedora Linux 38 (Workstation Edition) 6.3.8-200.fc38.x86_64, locale en_GB.UTF-8)
    • Flutter version 3.7.10 on channel stable at /home/manuel/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4b12645012 (3 months 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.1)
    • Android SDK at /home/manuel/Android/Sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (Red_Hat-17.0.7.0.7-4.fc38) (build 17.0.7+7)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 16.0.5 (Fedora 16.0.5-1.fc38)
    • cmake version 3.26.4
    • ninja version 1.11.1
    • pkg-config version 1.8.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] IntelliJ IDEA Community Edition (version 2022.3)
    • IntelliJ at /home/manuel/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/223.8836.41
    • Flutter plugin version 74.0.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1)
    • IntelliJ at /home/manuel/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34
    • Flutter plugin version 73.1.1
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Fedora Linux 38 (Workstation Edition) 6.3.8-200.fc38.x86_64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 114.0.5735.198

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

```

</details>