首页 > 解决方案 > 慢慢滚动列表

问题描述

我希望能够滚动到列中的特定小部件。此解决方案有效,但我找不到滚动速度较慢的方法,因为使用此方法您可以立即到达小部件。我也不能使用滚动索引包,因为我的小部件在滚动时应该是动画的,这是不可能的。有谁知道如何通过这个列表更慢地滚动?

class ScrollView extends StatelessWidget {
 final dataKey = new GlobalKey();

 @override
 Widget build(BuildContext context) {
   return new Scaffold(
     primary: true,
     appBar: new AppBar(
       title: const Text('Home'),
     ),
     body: new SingleChildScrollView(
       child: new Column(
         children: <Widget>[
           new SizedBox(height: 160.0, width: double.infinity, child: new Card()),
           new SizedBox(height: 160.0, width: double.infinity, child: new Card()),
           new SizedBox(height: 160.0, width: double.infinity, child: new Card()),
           // destination
           new Card(
             key: dataKey,
             child: new Text("data\n\n\n\n\n\ndata"),
           )
         ],
       ),
     ),
     bottomNavigationBar: new RaisedButton(
       onPressed: () => Scrollable.ensureVisible(dataKey.currentContext),
       child: new Text("Scroll to data"),
     ),
   );
 }
}

标签: flutterdart

解决方案


推荐阅读