是否可以撰寫一個函式來創建影片控制器?我有動態資料,如果我的資料回傳 3,我需要創建 3 個影片控制器。
編輯:謝謝你 pskink 的List.generate想法。如果我想使用以下函式手動觸發 ( List<AnimationController> animationList)
createAnimationController(int sec, String id) {
animationList
.add(AnimationController(vsync: this, duration: Duration(seconds: sec))
..addListener(() {
print('hello');
update([id]);
}));
return animationList.last; }
我注意到我的聽眾沒有開火,不知道為什么。
uj5u.com熱心網友回復:
來自pskink的回答
回傳新生成的作業代碼AnimationController:
List<AnimationController> animationList;
createAnimationController(int sec, String id) {
animationList
.add(AnimationController(vsync: this, duration: Duration(seconds: sec))..forward()
..addListener(() {
update([id]);
}));
return animationList.last;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/459091.html
上一篇:每當滑鼠在螢屏上時如何觸發功能
下一篇:如何在加載CSS時運行影片
