Repository: flutter
Issue: SliverReorderableList has different behavior than ReorderableListView when children are stateful
Labels: framework,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.27,found in release: 3.28

### Steps to reproduce

States of stateful children of `SliverReorderableList` are destroyed if their widgets are re-ordered.

1- Run the code sample as it is
2- Tap on widget with item ID: 2 (It will turn blue)
3- Drag widget with item ID: 1, and place it right under item ID: 2 (Observe that itemID: 2 retains its state and stays blue)
4- Replace the `BoxTestScreen` in the `MaterialApp`'s `home` argument with `SliverTestScreen`
5- Repeat steps 1, 2, and 3 (Observe that itemID: 2 does not retain its state and reverts back to red)
6- Hot restart on the `SliverTestScreen`
7- Tap on widget with item ID: 2 (It will turn blue)
8- Drag widget with item ID: 6, and place it under item ID: 7 (Observe that itemID: 2 retains its state and stays blue)

### Expected results

The two widgets should have the same behavior which would cause the stateful children to retain their states as long as the same keys are provided (as is done in this example).

### Actual results

 In the case of `SliverReorderableList` the expected result doesn't happen and the widget's state isn't retained.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const BoxTestScreen(),
    );
  }
}

class BoxTestScreen extends StatelessWidget {
  const BoxTestScreen({super.key});

  static final List<int> randomIntegers = List.generate(10, (index) => index);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Box Test Screen'),
      ),
      body: ReorderableListView.builder(
        itemCount: randomIntegers.length,
        itemBuilder: (context, index) => _buildItem(index),
        onReorder: (oldIndex, newIndex) {
          final correctedNewIndex = newIndex > oldIndex ? newIndex - 1 : newIndex;

          final int item = randomIntegers.removeAt(oldIndex);
          randomIntegers.insert(correctedNewIndex, item);
        },
      ),
    );
  }

  Widget _buildItem(int index) {
    return Padding(
      key: ValueKey(randomIntegers[index]),
      padding: const EdgeInsets.all(8.0),
      child: StatefulItem(
        id: randomIntegers[index],
        index: index,
      ),
    );
  }
}

class SliverTestScreen extends StatelessWidget {
  const SliverTestScreen({super.key});

  static final List<int> randomIntegers = List.generate(10, (index) => index);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Sliver Test Screen'),
      ),
      body: CustomScrollView(
        slivers: [
          SliverReorderableList(
            itemCount: randomIntegers.length,
            itemBuilder: (context, index) => _buildItem(index),
            onReorder: (oldIndex, newIndex) {
              final correctedNewIndex = newIndex > oldIndex ? newIndex - 1 : newIndex;

              final int item = randomIntegers.removeAt(oldIndex);
              randomIntegers.insert(correctedNewIndex, item);
            },
          )
        ],
      ),
    );
  }

  Widget _buildItem(int index) {
    return Padding(
      key: ValueKey(randomIntegers[index]),
      padding: const EdgeInsets.all(8.0),
      child: StatefulItem(
        id: randomIntegers[index],
        index: index,
      ),
    );
  }
}

class StatefulItem extends StatefulWidget {
  const StatefulItem({
    super.key,
    required this.id,
    required this.index,
  });

  final int id;
  final int index;

  @override
  State<StatefulItem> createState() => _StatefulItemState();
}

class _StatefulItemState extends State<StatefulItem> with AutomaticKeepAliveClientMixin {
  Color _color = Colors.red;

  @override
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return GestureDetector(
      onTap: () {
        setState(() {
          _color = _color == Colors.red ? Colors.blue : Colors.red;
        });
      },
      child: ColoredBox(
        color: _color,
        child: Row(
          children: [
            Text('Item ID: ${widget.id}'),
            Spacer(),
            ReorderableDragStartListener(
              index: widget.index,
              child: IconButton(
                icon: const Icon(Icons.drag_handle),
                onPressed: () {
                  setState(() {
                    _color = _color == Colors.red ? Colors.blue : Colors.red;
                  });
                },
              ),
            )
          ],
        ),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

`ReorderableListView`
https://github.com/user-attachments/assets/65876d70-2704-4b72-959a-d94f8c1e2a16

`SliverReorderableList`
https://github.com/user-attachments/assets/1d88e124-2eff-44bc-b89c-660d2d05e360



</details>


### Logs

_No response_

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.27.1, on macOS 15.1 24B83 darwin-arm64, locale en-EG)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google
    Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.96.2)
[✓] VS Code (version 1.95.1)
[✓] Connected device (4 available)
[✓] Network resources
```

</details>