animateToScrollPosition method

void animateToScrollPosition(
  1. double position
)

Implementation

void animateToScrollPosition(double position) {
  var position0 = position;
  if (position < 0) position0 = 0;
  if (position > widget.constraints.width - widget.scrollWidth) {
    position0 = widget.constraints.width - widget.scrollWidth;
  }
  setState(() {
    scrollPosition = position0;
  });
  widget.scrollController.animateTo(position0 * widget.scale,
      duration: const Duration(milliseconds: 200), curve: Curves.ease);
}