MaterialScrollBehavior class Null safety

Describes how Scrollable widgets behave for MaterialApps.

Used by ScrollConfiguration to configure the Scrollable widgets in a subtree.

This class can be extended to further customize a ScrollBehavior for a subtree. For example, overriding ScrollBehavior.getScrollPhysics sets the default ScrollPhysics for Scrollables that inherit this ScrollConfiguration. Overriding ScrollBehavior.buildOverscrollIndicator can be used to add or change the default GlowingOverscrollIndicator decoration, while ScrollBehavior.buildScrollbar can be changed to modify the default Scrollbar.

When looking to easily toggle the default decorations, you can use ScrollBehavior.copyWith instead of creating your own ScrollBehavior class. The scrollbar and overscrollIndicator flags can turn these decorations off.

Setting a MaterialScrollBehavior will apply a GlowingOverscrollIndicator to Scrollable descendants when executing on and TargetPlatform.fuchsia.

When using the desktop platform, if the Scrollable widget scrolls in the Axis.vertical, a Scrollbar is applied.

If the scroll direction is Axis.horizontal scroll views are less discoverable, so consider adding a Scrollbar in these cases, either directly or through the buildScrollbar method.

MaterialScrollBehavior.androidOverscrollIndicator specifies the overscroll indicator that is used on When null, ThemeData.androidOverscrollIndicator is used. If also null, the default overscroll indicator is the GlowingOverscrollIndicator. These properties are deprecated. In order to use the StretchingOverscrollIndicator, use the ThemeData.useMaterial3 flag, or override ScrollBehavior.buildOverscrollIndicator.

See also:

  • ScrollBehavior, the default scrolling behavior extended by this class.


MaterialScrollBehavior({@Deprecated('Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. ' 'This feature was deprecated after v2.13.0-0.0.pre.') AndroidOverscrollIndicator? androidOverscrollIndicator})
Creates a MaterialScrollBehavior that decorates Scrollables with GlowingOverscrollIndicators and Scrollbars based on the current platform and provided ScrollableDetails.


androidOverscrollIndicator AndroidOverscrollIndicator
Specifies which overscroll indicator to use on
dragDevices Set<PointerDeviceKind>
The device kinds that the scrollable will accept drag gestures from.
hashCode int
The hash code for this object.
runtimeType Type
A representation of the runtime type of the object.


buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) Widget
Applies a GlowingOverscrollIndicator to the child widget on and TargetPlatform.fuchsia.
buildScrollbar(BuildContext context, Widget child, ScrollableDetails details) Widget
Applies a RawScrollbar to the child widget on desktop platforms.
copyWith({bool? scrollbars, bool? overscroll, Set<PointerDeviceKind>? dragDevices, ScrollPhysics? physics, TargetPlatform? platform, AndroidOverscrollIndicator? androidOverscrollIndicator}) ScrollBehavior
Creates a copy of this ScrollBehavior, making it possible to easily toggle scrollbar and overscrollIndicator effects.
getPlatform(BuildContext context) TargetPlatform
The platform whose scroll physics should be implemented.
getScrollPhysics(BuildContext context) ScrollPhysics
The scroll physics to use for the platform given by getPlatform.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
shouldNotify(covariant ScrollBehavior oldDelegate) bool
Called whenever a ScrollConfiguration is rebuilt with a new ScrollBehavior of the same runtimeType.
toString() String
A string representation of this object.
velocityTrackerBuilder(BuildContext context) GestureVelocityTrackerBuilder
Specifies the type of velocity tracker to use in the descendant Scrollables' drag gesture recognizers, for estimating the velocity of a drag gesture.


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