ScrollController class

Controls a scrollable component, allowing programmatic scrolling and listening to scroll notifications.

Implementers

Constructors

ScrollController({double initialScrollOffset = 0.0, ScrollDirection direction = ScrollDirection.vertical})
Creates a new ScrollController.

Properties

direction → ScrollDirection
Direction of scrolling (horizontal or vertical).
final
hasClients → bool
Returns true if the controller is attached to an HTML DOM element.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasReachedEnd → bool
Returns true if the controller has reached the end of the scrollable component.
no setter
isAtStart → bool
Returns true if the controller is at the start of the scrollable component.
no setter
isScrollable → bool
Whether the attached element is a scrollable container.
no setter
maxScrollExtent → double
Maximum scroll extent based on direction (scrollHeight/clientHeight or scrollWidth/clientWidth).
no setter
minScrollExtent → double
Minimum scroll extent (usually 0.0).
no setter
offset → double
The current scroll offset in pixels based on direction.
no setter
position → double
Alias for current scroll position based on direction.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Adds a scroll position listener callback.
animateTo(double value, {Duration duration = const Duration(milliseconds: 300), Curves curve = Curves.easeInOut}) → void
Animates the scroll position smoothly to value in pixels.
animateToIndex(int index, {required double itemExtent, Duration duration = const Duration(milliseconds: 300), Curves curve = Curves.easeInOut}) → void
Animates smoothly to a specific item index given a fixed itemExtent in pixels.
attach(HTMLElement element) → void
Attaches the controller to a rendered HTML element.
detach() → void
Detaches the controller from the HTML element.
dispose() → void
Disposes resources used by the controller.
jumpTo(double value) → void
Jumps the scroll position immediately to value in pixels.
jumpToIndex(int index, {required double itemExtent}) → void
Jumps immediately to a specific item index given a fixed itemExtent in pixels.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Notifies all registered listeners.
removeListener(VoidCallback listener) → void
Removes a scroll position listener callback.
scrollToComponent(String id, {Duration duration = const Duration(milliseconds: 300), Curves curve = Curves.easeInOut}) → void
Scrolls to a specific component inside the scrollable component.
scrollToEnd() → void
Jumps the scroll position to the end of the scrollable component.
scrollToTop() → void
Jumps the scroll position to the top of the scrollable component.
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

isElementScrollable(HTMLElement? element) → bool
Helper method to check whether an element is a scrollable container.