Scrollbar class Null safety

A Material Design scrollbar.

To add a scrollbar to a ScrollView, wrap the scroll view widget in a Scrollbar widget.

A scrollbar thumb indicates which portion of a ScrollView is actually visible.

By default, the thumb will fade in and out as the child scroll view scrolls. When isAlwaysShown is true, the scrollbar thumb will remain visible without the fade animation. This requires that a ScrollController is provided to controller, or that the PrimaryScrollController is available.

If the scrollbar is wrapped around multiple ScrollViews, it only responds to the nearest scrollView and shows the corresponding scrollbar thumb by default. Set notificationPredicate to something else for more complicated behaviors.

Scrollbars are interactive and will also use the PrimaryScrollController if a controller is not set. Scrollbar thumbs can be dragged along the main axis of the ScrollView to change the ScrollPosition. Tapping along the track exclusive of the thumb will trigger a ScrollIncrementType.page based on the relative position to the thumb.

If the child ScrollView is infinitely long, the RawScrollbar will not be painted. In this case, the scrollbar cannot accurately represent the relative location of the visible area, or calculate the accurate delta to apply when dragging on the thumb or tapping on the track.

Dynamically changes to an iOS style scrollbar that looks like CupertinoScrollbar on the iOS platform.

The color of the Scrollbar will change when dragged. A hover animation is also triggered when used on web and desktop platforms. A scrollbar track can also been drawn when triggered by a hover event, which is controlled by showTrackOnHover. The thickness of the track and scrollbar thumb will become larger when hovering, unless overridden by hoverThickness.

See also:

  • RawScrollbar, a basic scrollbar that fades in and out, extended by this class to add more animations and behaviors.
  • ScrollbarTheme, which configures the Scrollbar's appearance.
  • CupertinoScrollbar, an iOS style scrollbar.
  • ListView, which displays a linear, scrollable list of children.
  • GridView, which displays a 2 dimensional, scrollable array of children.
Inheritance

Constructors

Scrollbar({Key? key, required Widget child, ScrollController? controller, bool? isAlwaysShown, bool? showTrackOnHover, double? hoverThickness, double? thickness, Radius? radius, ScrollNotificationPredicate? notificationPredicate})
Creates a material design scrollbar that by default will connect to the closest Scrollable descendant of child. [...]
const

Properties

child Widget
The widget below this widget in the tree. [...]
final
controller ScrollController?
The ScrollController used to implement Scrollbar dragging. [...]
final
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
hoverThickness double?
The thickness of the scrollbar when a hover state is active and showTrackOnHover is true. [...]
final
isAlwaysShown bool?
Indicates that the scrollbar should be visible, even when a scroll is not underway. [...]
final
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
notificationPredicate ScrollNotificationPredicate?
A check that specifies whether a ScrollNotification should be handled by this widget. [...]
final
radius Radius?
The color of the scrollbar thumb. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
showTrackOnHover bool?
Controls if the track will show on hover and remain, including during drag. [...]
final
thickness double?
The thickness of the scrollbar in the cross axis of the scrollable. [...]
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
createState() → _ScrollbarState
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. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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. [...]
@nonVirtual, inherited