Repository: flutter
Issue: SelectableText with NeverScrollableScrollPhysics needs unique PageStorageKey to not conflict with parent Scrollable
Labels: framework,f: material design,f: scrolling,has reproducible steps,P2,found in release: 3.10,found in release: 3.12,team-design,triaged-design

### 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. Run the example (best on iOS)
2. Open "Tab 0"
3. Scroll down until the text is visible
4. Make sure that scrolling has ended, so that it got persisted in page storage
5. Switch to "Tab 1"
6. Switch back to "Tab 0"
7. Notice that the scroll position got restored correctly, but that the text scrolls weirdly
9. Switch back to "Tab 1"
10. Switch back to "Tab 0" and notice that the scroll position did reset to 0

### Expected results

- Text should not scroll, because it has `NeverScrollableScrollPhysics` set.
- Scroll position should not reset to 0, but stay at the previous position.

### Actual results

- Text scrolls, obviously restoring its scroll state from the previously stored scroll position of the parent `ListView`.
- Scroll position resets to 0, because this is what the `SelectableText` persisted to page storage.

It works, when the `SelectableText` gets its own unique `PageStorageKey`, however this is not very obvious because:
- you (me at least) don't expect that `SelectableText` can actually scroll.
- a scrollable with `NeverScrollableScrollPhysics` should have scrolling disabled.

### Code sample

<details><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

final _bucket = PageStorageBucket();

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: PageStorageBug(),
    );
  }
}

class PageStorageBug extends StatefulWidget {
  const PageStorageBug({Key? key}) : super(key: key);

  @override
  State<PageStorageBug> createState() => _PageStorageBugState();
}

class _PageStorageBugState extends State<PageStorageBug> {
  int _tabIndex = 0;

  @override
  Widget build(BuildContext context) {
    return PageStorage(
      bucket: _bucket,
      child: Scaffold(
        body: _tabIndex == 0
            ? const Tab(key: ValueKey(0), title: "Tab 0")
            : const Tab(key: ValueKey(1), title: "Tab 1"),
        bottomNavigationBar: BottomNavigationBar(
          currentIndex: _tabIndex,
          items: const [
            BottomNavigationBarItem(
              icon: Icon(Icons.access_alarm),
              label: "Tab 0",
            ),
            BottomNavigationBarItem(icon: Icon(Icons.add), label: "Tab 1")
          ],
          onTap: (index) => setState(() => _tabIndex = index),
        ),
      ),
    );
  }
}

class Tab extends StatelessWidget {
  final String title;

  const Tab({required this.title, Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Scrollbar(
        child: ListView(
          key: PageStorageKey("$title-main"),
          children: [
            Container(height: 1000, color: Colors.blue),
            SelectableText(
              // It obviously works, when this key is set.
              //key: PageStorageKey("$title-text"),
              title,
              style: const TextStyle(fontSize: 50),
              scrollPhysics: const NeverScrollableScrollPhysics(),
            ),
            Container(height: 3000, color: Colors.red),
          ],
        ),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>


https://github.com/flutter/flutter/assets/26022902/40879987-31c6-4d83-b2bf-da5197ee6b3f


</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.10.5, on macOS 13.4 22F66 darwin-arm64, locale en-DE)
    • Flutter version 3.10.5 on channel stable at /Users/tobias/dev/tools/flutter
    ! Warning: `flutter` on your path resolves to /Users/tobias/Dev/Tools/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/tobias/dev/tools/flutter. Consider adding /Users/tobias/dev/tools/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/tobias/Dev/Tools/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/tobias/dev/tools/flutter. Consider adding /Users/tobias/dev/tools/flutter/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (6 days ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1
    • 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 33.0.2)
    • Android SDK at /Users/tobias/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • ANDROID_HOME = /Users/tobias/Library/Android/sdk
    • Java binary at: /Users/tobias/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • 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.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Users/tobias/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9619390/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.15+0-b2043.56-8887301)

[✓] Android Studio (version 2022.2)
    • Android Studio at /Users/tobias/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/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 17.0.6+0-17.0.6b802.4-9586694)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
    • IntelliJ at /Users/tobias/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 73.1.1
    • Dart plugin version 231.9065

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1)
    • IntelliJ at /Users/tobias/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8109.175/IntelliJ IDEA.app
    • 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

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
    • IntelliJ at /Users/tobias/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34/IntelliJ IDEA.app
    • 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

[✓] VS Code (version 1.79.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)
    • KrasserDude (mobile)   • 79aa79a8f05d850905d52818fde5eea8d1b898ff • ios            • iOS 15.1 19B74
    • iPhone 14 Pro (mobile) • 81F2A201-82A9-4AF1-B8E6-6069F3222FB0     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)        • macos                                    • darwin-arm64   • macOS 13.4 22F66 darwin-arm64
    • Chrome (web)           • chrome                                   • web-javascript • Google Chrome 114.0.5735.133

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
```

</details>