ScrollNotification class

A Notification related to scrolling.

Scrollable widgets notify their ancestors about scrolling-related changes. The notifications have the following lifecycle:

Notifications bubble up through the tree, which means a given NotificationListener will receive notifications for all descendant Scrollable widgets. To focus on notifications from the nearest Scrollable descendant, check that the depth property of the notification is zero.

When a scroll notification is received by a NotificationListener, the listener will have already completed build and layout, and it is therefore too late for that widget to call State.setState. Any attempt to adjust the build or layout based on a scroll notification would result in a layout that lagged one frame behind, which is a poor user experience. Scroll notifications are therefore primarily useful for paint effects (since paint happens after layout). The GlowingOverscrollIndicator and Scrollbar widgets are examples of paint effects that use scroll notifications.

To drive layout based on the scroll position, consider listening to the ScrollPosition directly (or indirectly via a ScrollController).

Inheritance
Mixed in types
Implementers

Constructors

ScrollNotification({@required ScrollMetrics metrics, @required BuildContext context })
Initializes fields for subclasses.

Properties

context BuildContext
The build context of the widget that fired this notification. [...]
final
metrics ScrollMetrics
A description of a Scrollable's contents, useful for modeling the state of its viewport.
final
depth int
The number of viewports that this notification has bubbled through. [...]
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

debugFillDescription(List<String> description) → void
Add additional information to the given description for use by toString. [...]
override
dispatch(BuildContext target) → void
Start bubbling this notification at the given build context. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited
visitAncestor(Element element) bool
Applied to each ancestor of the dispatch target. [...]
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited