首页 > 解决方案 > 如何在颤动中实现字母滚动

问题描述

是否有任何插件或方法可以在颤动中实现这种滚动?

具体来说,就是右边的字母列,比如高亮当前的字母,或者如果一个字母被轻敲,scrollview直接进入那个字母的标题。

对于按字母顺序排序,我们可以使用List.sort(), 对于粘性标题,我们也有一些不错的插件。

联系人列表 iamge

标签: dartflutter

解决方案


签出这个插件粘头 https://pub.dartlang.org/packages/sticky_headers

class Example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new ListView.builder(itemBuilder: (context, index) {
      return new StickyHeader(
        header: new Container(
          height: 50.0,
          color: Colors.blueGrey[700],
          padding: new EdgeInsets.symmetric(horizontal: 16.0),
          alignment: Alignment.centerLeft,
          child: new Text('Header #$index',
            style: const TextStyle(color: Colors.white),
          ),
        ),
        content: new Container(
          child: new Image.network(imageForIndex(index), fit: BoxFit.cover,
            width: double.infinity, height: 200.0),
        ),
      );
    });
  }
}

推荐阅读