ScrollMetrics mixin

A description of a Scrollable's contents, useful for modeling the state of its viewport.

This class defines a current position, pixels, and a range of values considered "in bounds" for that position. The range has a minimum value at minScrollExtent and a maximum value at maxScrollExtent (inclusive). The viewport scrolls in the direction and axis described by axisDirection and axis.

The outOfRange getter will return true if pixels is outside this defined range. The atEdge getter will return true if the pixels position equals either the minScrollExtent or the maxScrollExtent.

The dimensions of the viewport in the given axis are described by viewportDimension.

The above values are also exposed in terms of extentBefore, extentInside, and extentAfter, which may be more useful for use cases such as scroll bars; for example, see Scrollbar.

This sample shows how a ScrollMetricsNotification is dispatched when the ScrollMetrics changed as a result of resizing the Viewport. Press the floating action button to increase the scrollable window's size.
link

To create a local project with this code sample, run:
flutter create --sample=widgets.ScrollMetrics.1 mysample

See also:

Mixin Applications

Properties

minScrollExtent double
The minimum in-range value for pixels.
no setter
maxScrollExtent double
The maximum in-range value for pixels.
no setter
hasContentDimensions bool
Whether the minScrollExtent and the maxScrollExtent properties are available.
no setter
pixels double
The current scroll position, in logical pixels along the axisDirection.
no setter
hasPixels bool
Whether the pixels property is available.
no setter
viewportDimension double
The extent of the viewport along the axisDirection.
no setter
hasViewportDimension bool
Whether the viewportDimension property is available.
no setter
axisDirection AxisDirection
The direction in which the scroll view scrolls.
no setter
axis Axis
The axis in which the scroll view scrolls.
no setter
outOfRange bool
Whether the pixels value is outside the minScrollExtent and maxScrollExtent.
no setter
atEdge bool
Whether the pixels value is exactly at the minScrollExtent or the maxScrollExtent.
no setter
extentBefore double
The quantity of content conceptually "above" the viewport in the scrollable. This is the content above the content described by extentInside.
no setter
extentInside double
The quantity of content conceptually "inside" the viewport in the scrollable (including empty space if the total amount of content is less than the viewportDimension).
no setter
extentAfter double
The quantity of content conceptually "below" the viewport in the scrollable. This is the content below the content described by extentInside.
no setter
extentTotal double
The total quantity of content available.
no setter
devicePixelRatio double
The FlutterView.devicePixelRatio of the view that the Scrollable associated with this metrics object is drawn into.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({double? minScrollExtent, double? maxScrollExtent, double? pixels, double? viewportDimension, AxisDirection? axisDirection, double? devicePixelRatio}) ScrollMetrics
Creates a ScrollMetrics that has the same properties as this object.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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