Scrollbar class

A scrollbar that decorates a scrollable child.

Provide a controller to read scroll metrics and enable dragging. By default, the scrollbar reserves space to the right; set overlay to true to draw it on top of the child.

For smooth gutters, use space characters with background styling and set trackUsesBackground or thumbUsesBackground to true. Use gutterWidth to reserve extra columns for the track, and roundedCaps to round the thumb ends.

Hover styling requires mouse all-motion mode.

Inheritance

Constructors

Scrollbar({required Widget child, required ScrollController controller, Style? trackStyle, Style? thumbStyle, ScrollbarGradient? trackGradient, ScrollbarGradient? thumbGradient, bool trackUsesBackground = false, bool thumbUsesBackground = false, String trackChar = '│', String thumbChar = '█', int thickness = 1, int? gutterWidth, bool roundedCaps = false, String? thumbCapTopChar, String? thumbCapBottomChar, bool enableHover = false, Style? hoverTrackStyle, Style? hoverThumbStyle, ScrollbarGradient? hoverTrackGradient, ScrollbarGradient? hoverThumbGradient, String? hoverTrackChar, String? hoverThumbChar, bool overlay = false, int gap = 0, int mouseWheelDelta = 3, bool enableDrag = true, String? zoneId, Key? key})

Properties

child Widget
The scrollable child to decorate.
final
children List<Widget>
Child widgets that receive forwarded messages.
no setterinherited
controller ScrollController
Scroll controller providing offset and extent information.
final
debugRenderObjectPassthrough bool
Whether this widget is intentionally transparent to render-object layouts.
no setterinherited
enableDrag bool
Whether dragging the thumb updates scroll offset.
final
enableHover bool
Whether hover styling is enabled (requires all-motion mouse mode).
final
focusable bool
Whether this widget can receive keyboard focus.
no setterinherited
gap int
Gap between the child and the scrollbar when overlay is false.
final
gutterWidth int?
Optional track width in columns (defaults to thickness).
final
hashCode int
The hash code for this object.
no setterinherited
hoverThumbChar String?
Optional thumb character when hovered.
final
hoverThumbGradient ScrollbarGradient?
Optional gradient for the thumb when hovered.
final
hoverThumbStyle Style?
Optional style for the thumb when hovered.
final
hoverTrackChar String?
Optional track character when hovered.
final
hoverTrackGradient ScrollbarGradient?
Optional gradient for the track when hovered.
final
hoverTrackStyle Style?
Optional style for the track when hovered.
final
id String
Unique identifier for this widget.
no setterinherited
key Key?
Key for preserving widget identity.
finalinherited
mouseWheelDelta int
Number of rows to scroll per mouse wheel tick.
final
overlay bool
Whether the scrollbar is drawn on top of the child.
final
roundedCaps bool
Whether to use rounded cap characters for the thumb.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
theme Theme
Access the current theme.
no setterinherited
thickness int
Width of the scrollbar in columns.
final
thumbCapBottomChar String?
Optional bottom cap character for the thumb.
final
thumbCapTopChar String?
Optional top cap character for the thumb.
final
thumbChar String
Character used for the thumb.
final
thumbGradient ScrollbarGradient?
Optional gradient for the scrollbar thumb.
final
thumbStyle Style?
Optional style for the scrollbar thumb.
final
thumbUsesBackground bool
Whether the thumb style should apply to the background.
final
trackChar String
Character used for the track.
final
trackGradient ScrollbarGradient?
Optional gradient for the scrollbar track.
final
trackStyle Style?
Optional style for the scrollbar track.
final
trackUsesBackground bool
Whether the track style should apply to the background.
final
zoneId String?
Optional zone id for mouse tracking.
final

Methods

buildCachedView<T>(T builder(), Object? cacheKey) → T
Returns a cached view if the cache key matches.
inherited
createState() State<StatefulWidget>
Creates the mutable State associated with this widget.
override
handleInit() Cmd?
Override this instead of init for widget-specific initialization.
inherited
handleIntercept(Msg msg) → (Widget, Cmd?)
Override this to handle messages before they reach children.
inherited
handleUpdate(Msg msg) → (Widget, Cmd?)
Override this to handle messages specific to this widget.
inherited
init() Cmd?
Called once when the widget is first mounted.
inherited
invalidateCachedView() → void
Clears any cached view for this widget.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
update(Msg msg) → (Model, Cmd?)
Handles messages by forwarding to children then calling handleUpdate.
inherited
view() Object
Renders the widget to a string or View.
inherited

Operators

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