circular_countdown_timer icon indicating copy to clipboard operation
circular_countdown_timer copied to clipboard

Show 1 instead of 0 for final second

Open jtkeyva opened this issue 3 years ago • 5 comments

Kinda weird seeing a 0 on a countdown when there is technically 1 second remaining. Can there be a switch or an offset? thanks

jtkeyva avatar Mar 18 '21 08:03 jtkeyva

+1

Would be great if this feature is added, seems like a common scenario when it's used as a count down timer.

ramith-ascentic avatar Jun 14 '21 07:06 ramith-ascentic

This is not a feature it is a bug in the code. I set it up as below with durations 12 so its the same as a clock. At 3 you should be 1/4 of the way around, and 6 1/2 the way around, 9 3/4 and at 12 or 0 the full way around, but below is what it looks like. It looks weird because it is wrong the text and the animation is i second ahead

duration: 12 initialDuration: 0

image

liveaffiliates avatar Jun 15 '21 05:06 liveaffiliates

@liveaffiliates I get your point, but there could be different scenarios where a 0 needs to be shown.

In the example you mentioned, even-though you've set the duration to be 12, it's actually 13 (extra 1 second for the 0). Therefore as OP mentioned, there should be an option where we could skip the 0 or add an offset.

ramith-ascentic avatar Jun 15 '21 05:06 ramith-ascentic

I just timed it with a stopwatch the timer is not even running for the correct amount of time

liveaffiliates avatar Jun 15 '21 07:06 liveaffiliates

Solved with pull request #35 , I personally had the same problem, and the solution I gave it was a bit more generic, allowing you to manually edit the text given a duration. Here is an example of how to solve this problem using the changes in pull request #35 : Possible solution 1: Replace only '0' with specific text. In the example of use in the code I specifically solve it by substituting the '0' for the 'GO'

timeFormatterFunction: (oldFormatterFunction, duration) {
 if (duration.inSeconds == 0) {
  return "GO";
 } else {
  return Function.apply(oldFormatterFunction, [duration]);
 }
}

Possible solution 2: Displace all the text one second with respect to the duration

timeFormatterFunction: (_, duration) {
 return '${duration.inSeconds + 1}';
}

JesusHdez960717 avatar Oct 27 '21 16:10 JesusHdez960717