onOptionsUpdate method

  1. @protected
  2. @mustCallSuper
void onOptionsUpdate(
  1. ParticleOptions? oldOptions
)

Implementation

@protected
@mustCallSuper
void onOptionsUpdate(ParticleOptions? oldOptions) {
  if (particles == null) return;
  if (particles!.length > options.particleCount)
    particles!.removeRange(0, particles!.length - options.particleCount);
  else if (particles!.length < options.particleCount) {
    final int particlesToSpawn = options.particleCount - particles!.length;
    final newParticles = generateParticles(particlesToSpawn);
    particles!.addAll(newParticles);
  }
}