Repository: flutter
Issue: PageView snapping breaks on web (Safari, ios) 
Labels: framework,f: scrolling,platform-web,p: video_player,package,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.22,found in release: 3.23

### Steps to reproduce

1. Put in the PageView items a video
2. Start scrolling from the bottom of the screen
3. Slowly scroll to the top of the screen (outside the browser viewport, in the example I scrolled to the battery icon)

### Expected results

The PageView should snap to the scrolled page without stop snapping to any item

### Actual results

The snap settings of the PageView stops working and it's possible to scroll to any position like the snapping is disabled

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Broken Page View',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final controllers = [
    VideoPlayerController.networkUrl(Uri.parse(
        "https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4")),
    VideoPlayerController.networkUrl(Uri.parse(
        "https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4")),
    VideoPlayerController.networkUrl(Uri.parse(
        "https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4")),
    VideoPlayerController.networkUrl(Uri.parse(
        "https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4")),
    VideoPlayerController.networkUrl(Uri.parse(
        "https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4")),
    VideoPlayerController.networkUrl(Uri.parse(
        "https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4")),
    VideoPlayerController.networkUrl(Uri.parse(
        "https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4")),
    VideoPlayerController.networkUrl(Uri.parse(
        "https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4")),
    VideoPlayerController.networkUrl(Uri.parse(
        "https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4")),
  ];

  bool isScrolling = false;

  late final PageController pageController;

  void _handleScrollChange() {
    if (isScrolling != pageController.position.isScrollingNotifier.value) {
      setState(() {
        isScrolling = pageController.position.isScrollingNotifier.value;
        if (isScrolling) {
          controllers[pageController.page?.toInt() ?? 0];
        }
      });
    }
  }

  void _handlePositionAttach(ScrollPosition position) {
    // From here, add a listener to the given ScrollPosition.
    // Here the isScrollingNotifier will be used to inform when scrolling starts
    // and stops and change the AppBar's color in response.
    position.isScrollingNotifier.addListener(_handleScrollChange);
  }

  void _handlePositionDetach(ScrollPosition position) {
    // From here, add a listener to the given ScrollPosition.
    // Here the isScrollingNotifier will be used to inform when scrolling starts
    // and stops and change the AppBar's color in response.
    position.isScrollingNotifier.removeListener(_handleScrollChange);
  }

  @override
  void initState() {
    super.initState();
    pageController = PageController(
      onAttach: _handlePositionAttach,
      onDetach: _handlePositionDetach,
    );

    controllers.forEach((c) async {
      c.setVolume(0);
      await c.initialize();
    });
    controllers[0].play();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text("Broken PageView"),
      ),
      body: PageView.builder(
        itemBuilder: itemBuilder,
        scrollDirection: Axis.vertical,
        itemCount: controllers.length,
        onPageChanged: (value) {
          controllers[value].play();
        },
        pageSnapping: true,
        controller: pageController,
      ),
    );
  }

  Widget itemBuilder(BuildContext context, int index) {
    return SizedBox.expand(
      child: VideoPlayer(controllers[index]),
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>


https://github.com/flutter/flutter/assets/112961248/e107d953-1846-49d6-8480-be974476207c



</details>


### Logs

<details open><summary>Logs</summary>
The build is run with the command

```shell
flutter run --web-renderer html
```
There are no logs or error shown in the console
</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale it-IT)
    • Flutter version 3.22.2 on channel stable at /Users/davide.quadrelli/flutter/flutter_3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (2 weeks ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] IntelliJ IDEA Community Edition (version 2024.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.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.90.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.90.0

[✓] VS Code (version 1.90.1)
    • VS Code at /Users/davide.quadrelli/dadolens/code/Code dadolens.app/Contents
    • Flutter extension version 3.90.0

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.62
    ! Error: Browsing on the local area network for iPhone di. Ensure the device is unlocked and attached with a cable or associated with the same
      local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for iPhone di . Ensure the device is unlocked and attached with a cable or associated with
      the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>