Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SheetPrimaryScrollPosition): ScrollSpringSimulation end point is … #444

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

theSharpestTool
Copy link

BUG FIX

Using CupertinoSheetRoute may cause unexpected scroll behavior.

STEPS TO REPRODUCE

  1. Run the provided example and open the sheet.
  2. Scroll down to the very bottom of the list, and during the bouncing effect, tap on an item (refer to the attached video).
  3. The list scrolls up unexpectedly
Screen.Recording.2024-12-19.at.16.58.45.mov
import 'package:flutter/material.dart';
import 'package:sheet/route.dart';

void main() => runApp(const MyApp());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: Scaffold(
        body: Center(
          child: Builder(
            builder: (context) {
              return TextButton(
                onPressed: () {
                  Navigator.of(context).push(
                    CupertinoSheetRoute<void>(
                      builder: (BuildContext context) =>
                          const CupertinoSheetWithScrollableList(),
                    ),
                  );
                },
                child: const Text('Open Sheet'),
              );
            },
          ),
        ),
      ),
    );
  }
}

class CupertinoSheetWithScrollableList extends StatelessWidget {
  const CupertinoSheetWithScrollableList({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        children: ListTile.divideTiles(
          context: context,
          tiles: List<Widget>.generate(
            100,
            (int index) => ListTile(
              title: Text('Item $index'),
            ),
          ),
        ).toList(),
      ),
    );
  }
}

This pull request includes a change to the SheetPrimaryScrollPosition class in the sheet/lib/src/scroll_controller.dart file. The change ensures that the pixels value does not exceed the maxScrollExtent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant