scrollTo method

dynamic scrollTo(
  1. double? position, {
  2. bool animate = false,
})

scrolls the widget with the specified context into view

Implementation

scrollTo(double? position, {bool animate = false}) {
  if (position == null) return;
  if (position < 0) position = 0;

  var max = controller.position.maxScrollExtent;
  if (position > max) position = max;

  if (animate) {
    controller.animateTo(position,
        duration: const Duration(milliseconds: 100),
        curve: Curves.easeOut);
  }
  else {
    controller.jumpTo(position);
  }
}