是否有任何插件或方法可以在 Flutter 中实现这种滚动?
具体来说,就是右边的字母列,比如高亮当前的字母,或者如果一个字母被点击,scrollview就直接到那个字母的标题。
对于按字母排序,我们可以使用 List.sort()
来实现,对于粘性标题,我们也有一些不错的插件。
最佳答案
checkout 这个插件粘头 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),
),
);
});
}
}
https://stackoverflow.com/questions/52817222/