Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timer not restarting itself #23

Closed
mikechari opened this issue Jun 15, 2021 · 3 comments
Closed

Timer not restarting itself #23

mikechari opened this issue Jun 15, 2021 · 3 comments
Assignees

Comments

@mikechari
Copy link

Hi I start the timer fine but then I want to restart the count down when the timer is done at onFinished with countdownController.restart() but it is not working, here is the widget.

@override
Widget build(BuildContext context) {

return Countdown(
  controller: countdownController,
  seconds: seconds,
  interval: const Duration(milliseconds: 500),
  build: (BuildContext context, double time) {
    countdownController.start();
    print(time);
    return child;
  },
  onFinished: () {
    print('timer done');
    countdownController.restart();
    if (mqttState == MqttAppConnectionState.connected) {
      print('TIMER::: Timer done retrying sending 1..');
    }
  },
  );
}

It prints the countdown at print(time): just fine the first time but the restart does not happen

I am doing something wrong? thanks!

@WiRight WiRight self-assigned this Jun 16, 2021
@WiRight
Copy link
Member

WiRight commented Jun 16, 2021

Yo!
I think the countdownController.start(); is not a good idea, cause build called every interval

I'll watch it later!

@WiRight
Copy link
Member

WiRight commented Jun 23, 2021

#24

@WiRight
Copy link
Member

WiRight commented Jun 23, 2021

Think it may be closed
Use newer version of 2.2.0

@WiRight WiRight closed this as completed Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants