Flutter:停止从 animateTo 函数滚动
Flutter: Stop scrolling from animateTo function
**
问题:如何停止函数 animateTo 的滚动?
**
根据我为 SingleChildScrollView
设置控制器
SingleChildScrollView(
padding: const EdgeInsets.all(10),
controller: _scrollController
当我点击按钮滚动。它会慢慢向下滚动到底部但功能
_scrollController.animateTo(
_scrollController.position.maxScrollExtent,
curve: Curves.linear,
duration: const Duration(milliseconds: 80000),
);
我想点击一个按钮来停止滚动
声明一个变量 var endPos
和 var animDuration
用以下内容替换代码的值
_scrollController.animateTo( endPos, curve: Curves.linear, duration: const Duration(milliseconds: animDuration), );
当您单击开始时,将值更改为 scrollController.position.maxScrollExtent 和 animDuration 8000。
单击停止时将值更新为
scrollController.position.pixels 和 animDuration 为 100。
** 问题:如何停止函数 animateTo 的滚动? ** 根据我为 SingleChildScrollView
设置控制器SingleChildScrollView(
padding: const EdgeInsets.all(10),
controller: _scrollController
当我点击按钮滚动。它会慢慢向下滚动到底部但功能
_scrollController.animateTo(
_scrollController.position.maxScrollExtent,
curve: Curves.linear,
duration: const Duration(milliseconds: 80000),
);
我想点击一个按钮来停止滚动
声明一个变量 var endPos
和 var animDuration
用以下内容替换代码的值
_scrollController.animateTo( endPos, curve: Curves.linear, duration: const Duration(milliseconds: animDuration), );
当您单击开始时,将值更改为 scrollController.position.maxScrollExtent 和 animDuration 8000。
单击停止时将值更新为 scrollController.position.pixels 和 animDuration 为 100。