Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 在计时器内产生块状态';s循环回调_Flutter_Dart_Bloc - Fatal编程技术网

Flutter 在计时器内产生块状态';s循环回调

Flutter 在计时器内产生块状态';s循环回调,flutter,dart,bloc,Flutter,Dart,Bloc,如何从计时器的循环回调中产生状态 我的类中有一个计时器对象,当用户点击开始时,它的一个新对象被创建,在它的回调中,我需要调用yield… 这是我到目前为止的代码,但它没有做任何事情: if (event is CounterETimerStart) { timer = Timer.periodic(Duration(seconds: 1), (timer) async* { yield CounterNewSecond(++m.passedTime);

如何
计时器的循环回调中产生
状态

我的类中有一个计时器对象,当用户点击开始时,它的一个新对象被创建,在它的回调中,我需要调用
yield…

这是我到目前为止的代码,但它没有做任何事情:

if (event is CounterETimerStart) {
        timer = Timer.periodic(Duration(seconds: 1), (timer) async* {
          yield CounterNewSecond(++m.passedTime);
        });
}

在github的@RollyPeres的帮助下,这是一种方法:

您可以添加事件并对其作出反应

if(事件为CounterETimerStart){
计时器=计时器。周期性(持续时间(秒:1),(计时器){
添加(TimerTicked());
});
}
如果(事件被时间勾选){
产量:秒(++m.passedTime);
}