我正在使用countdown_flutter组件进行倒计时。启动时,它可以正常工作。但是,我想重新启动计数器(再次调用该组件),以便在按下按钮或其他操作时再次开始倒计时:
我的代码:
_buildCount() {
return Expanded(
child: Container(
child: Center(
child: CountdownFormatted(
duration: Duration(seconds: 15),
onFinish: () {
_controller.nextQuestion();
print('finished!');
},
builder: (BuildContext ctx, String remaining) {
return Text(
remaining,
style: TextStyle(fontSize: 20),
); // 01:00:00
},
),
),
),
);
}
onNext: () {
setState(() {
_scoreKeeper.add(
Icon(
correct ? Icons.check : Icons.close,
color: correct ? Colors.green : Colors.red,
),
);
if (_scoreKeeper.length < _controller.number) {
_buildCount(); // I would like to recall him here
_controller.nextQuestion();
} else {
_stopWatch.stop();
FinishDialog.show(
context,
usuarioLogado: usuarioLogado,
);
}
});
},
答案 0 :(得分:0)
我在问答游戏中也使用了倒数计时,我意识到它就像下面的代码示例一样。
首次可以在initState方法中设置倒计时值,然后可以编写resetTimer()函数来重置倒计时。您可以通过RaisedButton或任何您需要的函数调用onPressed函数。不要忘记使用cancel()函数取消计时器。
Select (select count(1)
from (Select distinct PolicyNumber
from FinancialExtracts.dbo.INDCONEX
where RunDate = '20200531') as IND_PolicyCount
) as IND_PolicyCount,
(Select count(1)
from (Select distinct PolicyNumber
from FinancialExtracts.dbo.INTCRDEX
where RunDate = '20200531') as INT_PolicyCount
) as INT_PolicyCount,
(Select count(1)
from (Select distinct PolicyNumber
from FinancialExtracts.dbo.RACT1CR1_01
where RunDate = '20200531') as RACT1_PolicyCount
) as RACT1_PolicyCount,
(Select count(1)
from (Select distinct PolicyNumber
from FinancialExtracts.dbo.RACT3CR1_01
where RunDate = '20200531') as RACT3_PolicyCount
) as RACT3_PolicyCount,