Skip to content
Open
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
8 changes: 7 additions & 1 deletion lib/scroll_snap_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class ScrollSnapList extends StatefulWidget {

final EdgeInsetsGeometry? listViewPadding;

final bool Function()? canIScroll;

ScrollSnapList(
{this.background,
required this.itemBuilder,
Expand Down Expand Up @@ -154,7 +156,8 @@ class ScrollSnapList extends StatefulWidget {
this.clipBehavior = Clip.hardEdge,
this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
this.dispatchScrollNotifications = false,
this.listViewPadding})
this.listViewPadding,
this.canIScroll})
: listController = listController ?? ScrollController(),
super(key: key);

Expand Down Expand Up @@ -383,6 +386,9 @@ class ScrollSnapListState extends State<ScrollSnapList> {

//only animate if not yet snapped (tolerance 0.01 pixel)
if ((scrollInfo.metrics.pixels - offset).abs() > 0.01) {
if (widget.canIScroll != null && !widget.canIScroll!()) {
return false;
}
_animateScroll(offset);
}
} else if (scrollInfo is ScrollUpdateNotification) {
Expand Down