infinite_marquee 0.0.1
infinite_marquee: ^0.0.1 copied to clipboard
无限滚动跑马灯,可以自定义跑马灯内容,并且可以手势交互和点击.
无限滚动跑马灯
Features #
自定义跑马灯
支持:自动滚动、无限循环、自定义跑马的内容。
支持:手势拖拽、点击。
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('无限滚动跑马灯'),
),
body: Column(
children: [
Container(
margin: EdgeInsets.only(top: 20),
height: 70,
child: InfiniteMarquee(
stepOffset: 1,
itemBuilder: (BuildContext context, int index) {
/// 自定义控件
return GestureDetector(
onTap: () {
print('点击了$index');
},
child: Container(
alignment: Alignment.center,
margin: const EdgeInsets.only(right: 10),
// padding: EdgeInsets.only(right: 10),
width: 90,
height: 70,
decoration: BoxDecoration(
color: index % 2 == 0 ? Colors.red : Colors.blue,
borderRadius: BorderRadius.circular(8),
),
child: Text('自定义$index'),
),
);
},
),
),
],
),
);
}