Skip to content

[scrollable_positioned_list] Fix manual scrolling accuracy. #469

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

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,8 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
return LayoutBuilder(
builder: (context, constraints) {
final cacheExtent = _cacheExtent(constraints);
return GestureDetector(
onPanDown: (_) => _stopScroll(canceled: true),
excludeFromSemantics: true,
return Listener(
onPointerDown: (_) => _stopScroll(canceled: true),
child: Stack(
children: <Widget>[
PostMountCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,25 @@ void main() {
expect(find.text('Item 70'), findsOneWidget);
expect(find.text('Item 50'), findsOneWidget);
});

testWidgets(
'List positioned with 5 at top then scroll up so item 3 is at top',
(WidgetTester tester) async {
// debugPrintGestureArenaDiagnostics = true;
final itemPositionsListener = ItemPositionsListener.create();
await setUpWidgetTest(tester,
initialIndex: 5, itemPositionsListener: itemPositionsListener);

await tester.drag(
find.byType(ScrollablePositionedList), const Offset(0, 2 * itemHeight));
await tester.pumpAndSettle();

expect(
itemPositionsListener.itemPositions.value
.firstWhere((position) => position.index == 3)
.itemLeadingEdge,
0);
});
}

bool collectSemanticNodes(SemanticsNode root, List<SemanticsNode> nodes) {
Expand Down