Flutter ScrollController 跳转至义底部

5 min read

要将ScrollController跳转到底部,可以使用animateTojumpTo方法。

  1. 使用animateTo方法:
_scrollController.animateTo(
  _scrollController.position.maxScrollExtent,
  duration: Duration(milliseconds: 500),
  curve: Curves.easeOut,
);
  1. 使用jumpTo方法:
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);

请注意,这些方法都需要一个ScrollController实例来控制滚动位置。确保在使用这些方法之前,该控制器已经绑定到你的ScrollView(例如ListView、GridView等)组件上。