我在 Android Studio 中有一个自定义 View
,它使用自定义动画每 x 毫秒更新一次。我现在正在尝试在 Dart 中实现这种行为。这就是Android Java中动画的实现方式。 (仅代表动画逻辑,不执行其他任何操作)
public class ItemAnim extends CountDownTimer {
public ItemAnim(long millisInFuture, long countdownInterval){
super(millisInFuture, countdownInterval);
}
@Override
public void onTick(long millisUntilFinished) {
// do anim stuff like setting a rotation angle variable etc...
// listener.animate(...) code
}
}
我现在正在 Dart/Flutter SDK 中寻找一个非常相似的类。
即每 countdownInterval
毫秒调用 onTick(millisUntilFinished)
的类
最佳答案
您可以使用
Timer.periodic(duration, callback)
它将重复任务直到取消
示例
var timer = Timer.periodic(Duration(seconds: 1), (Timer t){
//your code here
});
取消使用
timer.cancel();
关于java - Android:Flutter SDK 中的 CountDownTimer 等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58017612/