将任何小部件转换为“跑马灯”效果。
跑马灯
| 参数 | 类型 | 描述 | 必需 | 默认值 |
|---|---|---|---|---|
| child | Widget | 是 | – | |
| pps | 双精度 | 每秒像素 | 否 | 15.0 |
| direction | 枚举 | 否 | MarqueerDirection.rtl | |
| 分隔符 | Widget | 否 | 空 | |
| 无限 | 布尔值 | 否 | 真 | |
| 交互 | 布尔 | 否 | 真 | |
| autoStart | 布尔 | 否 | 真 | |
| interactionRestart | 布尔值 | 否 | 真 | |
| interactionRestartDuration | 持续时间 | 否 | Duration(seconds: 3) | |
| 控制器 | MarqueerController | 否 | 空 | |
| onChangeItemInViewPort | void Function(index int) | callback | 否 | 空 |
| onInteraction | void Function() | callback | 否 | 空 |
| onStarted | void Function() | callback | 否 | 空 |
| onStoped | void Function() | callback | 否 | 空 |
final controller = MarqueerController();
/// controller.start()
/// controller.stop()
/// controller.interactionEnabled(false)
SizedBox(
height: 30,
child: Marqueer(
pps: 100, /// optional
controller: controller, /// optional
direction: MarqueerDirection.rtl, /// optional
restartAfterInteractionDuration: const Duration(seconds: 6), /// optional
restartAfterInteraction: false, /// optional
onChangeItemInViewPort: (index) {
print('item index: $index');
},
onInteraction: () {
print('on interaction callback');
},
onStarted: () {
print('on started callback');
},
onStoped: () {
print('on stopped callback');
},
child: const Text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pretium massa mollis lorem blandit imperdiet. Nulla mattis vitae mauris vel condimentum. Nam posuere, augue vitae lobortis consequat, odio ante condimentum est, at maximus augue purus id metus. Curabitur condimentum aliquet ante at aliquet. Quisque vel massa congue, bibendum leo sodales, malesuada ante. Maecenas sed tortor quis ipsum dictum sollicitudin.',
),
),
);
基本用法
SizedBox(
height: 50,
child:Marqueer(
child: AnyWidget()
)
)
