update method

void update(
  1. ScrollMetrics metrics,
  2. AxisDirection axisDirection
)

Update with new ScrollMetrics. If the metrics change, the scrollbar will show and redraw itself based on these new metrics.

The scrollbar will remain on screen.

Implementation

void update(
  ScrollMetrics metrics,
  AxisDirection axisDirection,
) {
  if (_lastMetrics != null &&
      _lastMetrics!.extentBefore == metrics.extentBefore &&
      _lastMetrics!.extentInside == metrics.extentInside &&
      _lastMetrics!.extentAfter == metrics.extentAfter &&
      _lastAxisDirection == axisDirection) {
    return;
  }

  final ScrollMetrics? oldMetrics = _lastMetrics;
  _lastMetrics = metrics;
  _lastAxisDirection = axisDirection;

  bool needPaint(ScrollMetrics? metrics) => metrics != null && metrics.maxScrollExtent > metrics.minScrollExtent;
  if (!needPaint(oldMetrics) && !needPaint(metrics)) {
    return;
  }
  notifyListeners();
}