Я использую компонент 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,
);
}
});
},