请查看这个粘性头部插件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),
),
);
});
}
}
List<YourModel>
来创建一个ListView
,然后在屏幕右侧使用FlatButtons
。当按钮被按下时,它们会滚动到该字母的第一个索引位置。 - Elcan