computeThumbMetrics method
Computes the thumb length and offset for the scrollbar.
Returns a record with thumbLength (the size of the scrollbar thumb) and
thumbOffset (its position in the scrollbar track).
Implementation
({double thumbLength, double thumbOffset}) computeThumbMetrics(
double viewportSize,
double minThumbLength,
) {
final thumbLength = max(
minThumbLength,
(viewportSize / contentSize) * viewportSize,
);
final maxThumbOffset = viewportSize - thumbLength;
final thumbOffset = scrollProgress * maxThumbOffset;
return (thumbLength: thumbLength, thumbOffset: thumbOffset);
}