【发布时间】:2020-01-02 20:19:33
【问题描述】:
我正在尝试在用户停止滚动后动画到列表视图中的特定点。但不知何故,当我在我的NotificationLister<ScrollEndNotification> 中使用_controller.animateTo(<parameters>) 时它不起作用。但是,当我使用 ScrollUpdateNotification 时它确实有效,但在这种情况下这是无用的。
Positioned(
right: 15,
top: 80,
width: 180,
height: 40,
child: Container(
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20))),
child: NotificationListener<ScrollEndNotification>(
onNotification: (ScrollEndNotification sn){
_controller.animateTo(60, duration: Duration(milliseconds: 500), curve: Curves.linear);
return true;
},
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: currencies.length,
itemBuilder: ((BuildContext ctxt, int index){
return Container(width: 60.0, child: Text(currencies[index].symbol, style: TextStyle(color: Theme.of(context).primaryColor, fontSize: 20),), alignment: Alignment.center);
}),
controller: _controller,
),
)
)
),
简而言之:我需要在用户停止滚动后为 ScrollView 的偏移设置动画
【问题讨论】:
-
答案已更新 - 请检查!!
标签: listview flutter flutter-layout