Scrollbar.list constructor
Scrollbar.list({})
Scrollbar for a ListView, including partial visibility within oversized items.
Unmeasured items count equally, so geometry is approximate for mixed
sizes. Dragging to either endpoint reaches the actual content edge.
Implementation
Scrollbar.list({
super.key,
/// The controller of the list in [child]; give that list the same
/// controller. The thumb follows [ListController.scrollFraction] and
/// [ListController.visibleFraction], and a click or drag on the bar calls
/// [ListController.jumpToFraction], which scrolls without moving the
/// list's cursor.
required ListController controller,
required this.child,
this.thickness = 1,
this.scrollDirection = Axis.vertical,
this.trackStyle = const CellStyle(dim: true),
this.thumbStyle = CellStyle.none,
this.showWhenFits = true,
}) : _metrics = (() {
// Fixed precision keeps the bar independent of whether the viewport
// spans many short items or part of one oversized item.
const units = 1000000;
final visible = (controller.visibleFraction * units).round();
return (
units,
visible,
(controller.scrollFraction * (units - visible)).round(),
);
}),
_scrollTo = controller.jumpToFraction;