我想创建始终自动滚动的文本(例如.continuous
中的标签swift
属性)。现在,我将SingleChildScrollView
和scrollController
一起使用
SchedulerBinding.instance.addPostFrameCallback((_) {
_scrollController.animateTo(_scrollController.position.maxScrollExtent,
duration: Duration(seconds: 3), curve: Curves.easeIn);
});
答案 0 :(得分:1)
您需要使用Marquee
属性在flutter中自动移动文本,因为有库可以这样做,请检查一下Marquee库
请检查代码
Marquee(
text: 'Some sample text that takes some space.',
style: TextStyle(fontWeight: FontWeight.bold),
scrollAxis: Axis.horizontal,
crossAxisAlignment: CrossAxisAlignment.start,
blankSpace: 20.0,
velocity: 100.0,
pauseAfterRound: Duration(seconds: 1),
startPadding: 10.0,
accelerationDuration: Duration(seconds: 1),
accelerationCurve: Curves.linear,
decelerationDuration: Duration(milliseconds: 500),
decelerationCurve: Curves.easeOut,
)