scrollToOffset method
Implementation
void scrollToOffset(double offset, int duration, bool animate) {
if (offset >= 0) {
// 预防滑动超出之后的异常回弹
var finalOffset = offset < scrollController.position.maxScrollExtent
? offset
: scrollController.position.maxScrollExtent;
if (animate) {
scrollController.animateTo(
finalOffset,
duration: Duration(milliseconds: duration),
curve: Curves.linearToEaseOut,
);
} else {
scrollController.jumpTo(finalOffset);
}
}
}