Repository: flutter
Issue: [PageView] The BouncingScrollPhysics is not applied when the scroll direction is scrolling up
Labels: framework,f: scrolling,has reproducible steps,team-framework,found in release: 3.27,found in release: 3.29

### Steps to reproduce

### Title
[PageView] The BouncingScrollPhysics is not applied when the scroll direction is scrolling up

---

### Question

I'm experiencing an issue with Flutter's `PageView` when using `BouncingScrollPhysics`. The behavior of the scroll physics changes unexpectedly when scrolling vertically and locking a specific page. Here's how you can reproduce the issue:

1. Scroll to page 6.
2. Press the lock button (to activate the lock).
3. Scroll up.



---

### Context

I am working on a video app similar to YouTube Shorts. In this app, I need to dynamically manage pages because I may need to reload the previously visited pages due to the limited number of `VideoPlayerController` instances I can create. This is why I introduced the `lock` functionality to control access to certain pages dynamically. However, this appears to interfere with the expected behavior of the `BouncingScrollPhysics`.

---


### Expected results

When scrolling sequentially (e.g., 0 → 1 → 2 → 3 → 4 → 5), the BouncingScrollPhysics blocks the scroll and rebounds as expected.
It should behave consistently regardless of the scroll direction or lock state.

### Actual results

The scroll index changes like this: 7 → 6 → 10.
The index jumps to 10 and is not blocked by the BouncingScrollPhysics.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'dart:math';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool lock = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Random Color PageView',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Random Color PageView'),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            setState(() {
              lock = !lock;
            });
          },
          child: const Icon(Icons.lock),
        ),
        body: RandomColorPageView(
          lock: lock,
        ),
      ),
    );
  }
}

class RandomColorPageView extends StatelessWidget {
  final Random _random = Random();

  RandomColorPageView({super.key, required this.lock});
  final bool lock;

  @override
  Widget build(BuildContext context) {
    return PageView.builder(
      physics: const BouncingScrollPhysics(),
      scrollDirection: Axis.vertical,
      itemBuilder: (context, index) {
        final Color randomColor = Color.fromARGB(
          255,
          _random.nextInt(256),
          _random.nextInt(256),
          _random.nextInt(256),
        );
        if (index == 5 && lock) {
          return null;
        }

        Widget child = Container(
          width: double.infinity,
          height: double.infinity,
          color: randomColor,
          child: Center(
            child: Text(
              'Page $index',
              style: const TextStyle(
                fontSize: 48,
                color: Colors.white,
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
        );

        if (lock) {
          child = ColoredBox(
            color: Colors.red,
            child: Padding(
              padding: const EdgeInsets.all(8),
              child: child,
            ),
          );
        }

        return child;
      },
    );
  }
}
```

</details>



### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>
### when scroll up

https://github.com/user-attachments/assets/63f18d06-fa57-42a1-9c18-8c35c4e721cd

</details>

### Logs

_No response_

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[!] Flutter (Channel [user-branch], 3.24.5, on macOS 14.5 23F79 darwin-arm64, locale en-HK)
    ! Flutter version 3.24.5 on channel [user-branch] at /Users/wtcheung/dev/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at
      https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision dec2ee5c1f (2 months ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3
    • 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 35.0.0)
    • Android SDK at /Users/wtcheung/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/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.10+0-17.0.10b1087.21-11609105)

[✓] VS Code (version 1.96.4)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (5 available)
    • A015 (mobile)                   • 00112346F004917           • android-arm64  • Android 15 (API
      35)
    • W T’s iPhone (mobile)           • 00008110-001A03E62EF0401E • ios            • iOS 17.6.1
      21G93
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.5
      23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.5
      23F79 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome
      131.0.6778.265

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.```

</details>