flutter - 如何知道 animated_text_kit 包中当前正在播放的文本?
问题描述
我想弄清楚但我不知道
这是我的代码,几乎相同的示例代码
SizedBox(
width: 250.0,
child: TypewriterAnimatedTextKit(
onTap: () {},
text: ['aaaaa','bbbbb','ccccc','ddddd'],
textStyle: TextStyle(
color: kBlueGray,
fontSize: 20.sp,
),
speed: Duration(milliseconds: 550),
textAlign: TextAlign.start,
),
),
文本列表实际上是搜索的关键字。所以我想让用户在没有文本字段输入的情况下进行搜索。
解决方案
这是我的答案
List<String> animatedTextList = ["Iron man", "Superman", "Joker", "Hulk", "Dude"];
String currentAnimatedText;
@override
void initState() {
currentAnimatedText = animatedTextList[0];
super.initState();
}
**********
SizedBox(
width: 0.60.sw,
child: Padding(
padding: EdgeInsets.all(4.h),
child: SizedBox(
width: 250.0,
child: TypewriterAnimatedTextKit(
onNext: (value, value2) {
currentAnimatedText =
animatedTextList[value + 1];
print(currentAnimatedText);
},
onTap: () {
print(currentAnimatedText);
},
text: animatedTextList,
textStyle: TextStyle(
color: kBlueGray,
fontSize: 20.sp,
),
speed: Duration(milliseconds: 550),
textAlign: TextAlign.start,
),
),
),
),
推荐阅读
- java - NetBeans 更改滚动条设计
- git - gitignore 规则不起作用
- c# - 在 WPF 中播放和录制 16 位 PCM(原始)音频字节
- ruby-on-rails - Rails 可以避免在生产中选择 VERSION 环境变量吗
- python - 如何使用 Python 读取/获取 PDF 格式的古吉拉特语?
- javascript - 使用 ajax 和 laravel 进行基于状态的过滤
- c++ - 如何仅通过父类对象限制对象创建?
- control-m - 控制 M 作业无法调用 peoplesoft 应用程序中的进程
- selenium - Selenium FindElement 按父 div
- java - Gradle android找不到符号上下文