farhanfadila1717 / slide_countdown

A Flutter package to create easy slide animation countdown / countup timer.
https://pub.dev/packages/slide_countdown
MIT License
59 stars 43 forks source link

CountUp bug and accompanying fix code! #61

Closed clayzx closed 7 months ago

clayzx commented 7 months ago

When set to countUp mode, there is an issue with carryover resulting in three-digit numbers, for example, 19 would become 110 in the next frame.

Fix code, raw_digit_item.dart file:

int minMax(int value) {
    if (widget.countUp) {
      if (value == maxDigit && !currentAndNextIsSame) {
        return 0;
      }

      if (currentAndNextIsSame) {
        return value;
      }

      return value + 1;
    }

    if (value == 0 && !currentAndNextIsSame) {
      return maxDigit;
    }

    if (currentAndNextIsSame) {
      return value;
    }

    return max(value - 1, 0);
  }

hope this can be merged into the main branch in the next release.

farhanfadila1717 commented 7 months ago

thanks @clayzx for filling this issue, sure, i'll added your code next release.

farhanfadila1717 commented 7 months ago

Already released on pubdev v1.6.0.