mingsnx / animated_digit

A scrolling digit animation widget
MIT License
37 stars 16 forks source link

Dynamic color change is not compatible #14

Open danijorda1 opened 11 months ago

danijorda1 commented 11 months ago

I am trying to run a colour animation on top of AnimatedDigitWidget but it doesn't seem to work:

AnimatedBuilder( animation: _colorAnimation!, builder: (context, child) { print("Current Color: ${_colorAnimation.value}"); return AnimatedDigitWidget( value: int.parse(snapshotStorage?.data?["balance"].toString() ?? "0")/100, textStyle: GoogleFonts.dmSans( fontSize: 34 ffem, fontWeight: FontWeight .w700, height: 1 ffem / fem, color: _colorAnimation?.value), //color: const Color(0xff171310)), fractionDigits: (int.parse(snapshotStorage?.data?["balance"].toString() ?? "0")/100) % 1 == 0 ? 0 : 2, suffix: " €", enableSeparator: true, duration: Duration(milliseconds: 700), curve: Curves.easeInOutCirc, ); }),

................

_controller = AnimationController( duration: Duration(milliseconds: 700), vsync: this, );

  _colorAnimation = ColorTween(begin: Colors.green, end: Colors.red).animate(_controller!);

   _controller!.forward();

How does AnimatedDigitWidget handle dynamic changes to its properties.?

danijorda1 commented 11 months ago

Looking at the code I don't see any logic in the AnimatedDigitWidget for animating color changes. The color provided to the textStyle property is static, and if it changes, the widget will redraw with the new color, but it won't animate between colors.