KirsApps/odometer

Avoid display leading 0 on animation when counting down

Closed this issue · 7 comments

I use your widget to display the remaining scores in a game. When the score goes from 1050 down to 970 it keeps showing 0970 during the animation. At the end it's correctly displayed without the leading 0

Here my code snippet

AnimatedSlideOdometerNumber(
          numberTextStyle: TextStyle(
            fontSize: 70,
            color: Colors.black,
            fontWeight: FontWeight.normal,
          ),
          letterWidth: 60,
          verticalOffset: -20,
          odometerNumber: OdometerNumber(points),
          duration: Duration(milliseconds: 750),
        ),

And the different states:
01-Before
02-During
03-End

Hey @FreddyKaiser 👋
Thanks for opening an issue!
I think it is normal behavior. A value is changing from 1 to 0, and the animation is showing. Which behavior do you think is more appropriate?

Maybe removing all leading 0, starting from the left, when the animation of this digit has been completed would be appropriate ?

@FreddyKaiser If I understand correctly, you described the current behavior that I had described in the message above. Do you agree?

Not exactly, right now when the counter reaches 0 it stays until the other digits have finished their animation. It should quickly remove the leading 0 when animation on this digit is done. Or is there a way to format the number and leave the leading 0, example 0231

@FreddyKaiser Ok, I'll think about it in the next release.

@FreddyKaiser Hi! I published new package's version. The OdometerTween keeps leading zeros if an end odometer number is smaller than a beginning number.