From 527927da82601ef7ee641937860c4e18ef193e17 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 2 Nov 2019 20:17:00 +0100 Subject: [PATCH] Fix little issues with countdown timer. --- lib/ui/widgets/countdown_widget.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ui/widgets/countdown_widget.dart b/lib/ui/widgets/countdown_widget.dart index 7ff56bc..9a112e0 100644 --- a/lib/ui/widgets/countdown_widget.dart +++ b/lib/ui/widgets/countdown_widget.dart @@ -30,7 +30,7 @@ class _CountdownWidgetState extends State { int get totalDuration => (widget.endTime - widget.startTime).abs(); String get remainingTimeStr { - final remaining = Duration(seconds: remainingTime); + final remaining = Duration(seconds: remainingTime.abs()); return tr( "%days% Days %hours% Hours %minutes% Minutes %seconds% Seconds", @@ -51,7 +51,10 @@ class _CountdownWidgetState extends State { } void _timerCb(Timer timer) { - if (!mounted) timer.cancel(); + if (!mounted) { + timer.cancel(); + return; + } setState(() {}); }