ScrollSnapList class

A ListView widget that able to "snap" or focus to an item whenever user scrolls.

Allows unrestricted scroll speed. Snap/focus event done on every ScrollEndNotification.

Contains ScrollNotification widget, so might be incompatible with other scroll notification.

Inheritance

Constructors

ScrollSnapList({Color? background, required Widget itemBuilder(BuildContext, int), ScrollController? listController, Curve curve = Curves.ease, bool allowAnotherDirection = true, int duration = 500, double? endOfListTolerance, bool focusOnItemTap = true, void focusToItem(int)?, required int itemCount, required double itemSize, Key? key, Key? listViewKey, EdgeInsetsGeometry? margin, required void onItemFocus(int), Function? onReachEnd, EdgeInsetsGeometry? padding, bool reverse = false, bool? updateOnScroll, double? initialIndex, Axis scrollDirection = Axis.horizontal, bool dynamicItemSize = false, double dynamicSizeEquation(double distance)?, double? dynamicItemOpacity, SelectedItemAnchor selectedItemAnchor = SelectedItemAnchor.MIDDLE, bool shrinkWrap = false, ScrollPhysics? scrollPhysics, Clip clipBehavior = Clip.hardEdge, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, bool dispatchScrollNotifications = false, EdgeInsetsGeometry? listViewPadding})

Properties

allowAnotherDirection bool
Allow List items to be scrolled using other direction (e.g scroll items vertically if ScrollSnapList axis is Axis.horizontal)
final
background Color?
List background
final
clipBehavior Clip
The content will be clipped (or not) according to this option.
final
curve Curve
Animation curve
final
dispatchScrollNotifications bool
If set to false(default) scroll notification bubbling will be canceled. Set to true to dispatch notifications to further ancestors.
final
duration int
Animation duration in milliseconds (ms)
final
dynamicItemOpacity double?
Custom Opacity of items off center
final
dynamicItemSize bool
Scale item's size depending on distance to center
final
dynamicSizeEquation → (double Function(double distance)?)
Custom equation to determine dynamic item scaling calculation
final
endOfListTolerance double?
Pixel tolerance to trigger onReachEnd. Default is itemSize/2
final
focusOnItemTap bool
Focus to an item when user tap on it. Inactive if the list-item have its own onTap detector (use state-key to help focusing instead).
final
focusToItem → (void Function(int)?)
Method to manually trigger focus to an item. Call with help of GlobalKey<ScrollSnapListState>.
final
hashCode int
The hash code for this object.
no setterinherited
initialIndex double?
An optional initial position which will not snap until after the first drag
final
itemBuilder Widget Function(BuildContext, int)
Widget builder.
final
itemCount int
Number of item in this list
final
itemSize double
Composed of the size of each item + its margin/padding. Size used is width if scrollDirection is Axis.horizontal, height if Axis.vertical.
final
key Key?
Global key that's used to call focusToItem method to manually trigger focus event.
final
keyboardDismissBehavior ScrollViewKeyboardDismissBehavior
ScrollViewKeyboardDismissBehavior the defines how this ScrollView will dismiss the keyboard automatically.
final
listController ScrollController
Allows external controller
final
listViewKey Key?
Global key that passed to child ListView. Can be used for PageStorageKey
final
listViewPadding EdgeInsetsGeometry?
final
margin EdgeInsetsGeometry?
Container's margin
final
onItemFocus → void Function(int)
Callback function when list snaps/focuses to an item
final
onReachEnd Function?
Callback function when user reach end of list.
final
padding EdgeInsetsGeometry?
Container's padding
final
reverse bool
Reverse scrollDirection
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollDirection Axis
ListView's scrollDirection
final
scrollPhysics ScrollPhysics?
How the scroll view should respond to user input.
final
selectedItemAnchor SelectedItemAnchor
Anchor location for selected item in the list
final
shrinkWrap bool
Whether the extent of the scroll view in the scrollDirection should be determined by the contents being viewed.
final
updateOnScroll bool?
Calls onItemFocus (if it exists) when ScrollUpdateNotification fires
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() ScrollSnapListState
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited