【发布时间】:2020-11-19 13:14:45
【问题描述】:
我想按下按钮向下滚动,正好是当前屏幕高度。
我已经尝试过这个Flutter: Scrolling to a widget in ListView,但没有多大帮助。
我在Scaffold 中使用SingleChildScrollView()。
【问题讨论】:
我想按下按钮向下滚动,正好是当前屏幕高度。
我已经尝试过这个Flutter: Scrolling to a widget in ListView,但没有多大帮助。
我在Scaffold 中使用SingleChildScrollView()。
【问题讨论】:
创建一个ScrollController。
final _controller = ScrollController();
您的回电。
void _onPressed() {
// Get the height you want to scroll to.
final screenHeight = MediaQuery.of(context).size.height;
// If you don't want any animation, use this:
_controller.jumpTo(screenHeight);
// Otherwise use this:
_controller.animateTo(screenHeight, curve: Curves.easeOut, duration: Duration(seconds: 1));
}
你的SingleChildScrollView:
SingleChildScrollView(
controller: _controller,
child: ...,
)
【讨论】:
setState。