Skip to content

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