Closed ravenblackx closed 3 years ago
Hey @ravenblackx, sorry for the delay in replying. As you figured out, the first pump will always start the cycle so whatever time is pumped will not count towards the accumulated elapsed value until the animation cycle has started (after first pump). Your solution for a pump of 0 seconds is good, but we opted to use -1 as the flag instead of null. We'll be submitting this fix shortly to pub.dev. Let us know if that helps solve this for you.
Give this a shot with flare_flutter: 2.0.6
. Thanks again for the feedback.
That did it, thanks.
In a test:
doesn't work - the animation will actually be at the 0ms position.
Same, doesn't work.
Works, (though at that point the animation should be at 401ms not at 400ms, and it's not!).
I think if, in flare_render_box.dart, you made _lastFrameTime null for "hasn't been set yet" rather than using 0 for unset, then pump(no duration) would update it to zero, and pump(some duration) after that would then advance it by that duration, bringing its behavior in line with that of other animations. ie. replace
double _lastFrameTime = 0.0;
withdouble _lastFrameTime;
replace_lastFrameTime = 0;
with_lastFrameTime = null;
replacedouble elapsedSeconds = _lastFrameTime == 0.0 ? 0.0 : t - _lastFrameTime;
withdouble elapsedSeconds = _lastFrameTime == null ? 0.0 : t - _lastFrameTime;
Also, while you're there, might as well replace
final double t = timestamp.inMicroseconds / Duration.microsecondsPerMillisecond / 1000.0;
withfinal double t = timestamp.inMicroseconds / Duration.microsecondsPerSecond;