Open NeroThroN opened 7 months ago
Do you have a sample app to reproduce? or some code? Normally you should be able to have the effect not resetting.
I have create this small sample code to recreate the behavior:
Each time the setState
function is called inside the _updateOrigin
method, the particles are reset and the explode animation start from scratch
Took time to answer but what kind of animation are you trying to achieve? Updating the origin through setState will trigger a refresh cause there is no way to know that the same explode effect. If you want to move the explode effect around, you can use a global key on Newton widget to access the current state and add a new exploding effect with a fixed particle count and that should achieve the desired effect. Something like:
void _updateOrigin(Timer timer) {
origin += const Offset(5, 5);
newtonKey.currentState?.addEffect(ExplodeEffect(
particleConfiguration: ParticleConfiguration(
shape: CircleShape(),
color: const SingleParticleColor(color: Colors.red),
size: const Size(10, 10),
),
effectConfiguration: EffectConfiguration(
origin: origin,
minAngle: -180,
maxAngle: 180,
particlesPerEmit: 10,
particleCount: 100
),
));
}
Each time an effect is modified, the animations are reset. For example to have a dynamic
origin
or to haveemitDuration
based on a dynamic value. Is there a way to keep the particles generated without everything being reset?