initParticles method

void initParticles(
  1. Rect rect,
  2. WidgetSpoilerConfig configuration
)

Sets up the spoiler’s particles via initializeParticles in the parent, then starts a periodic timer that spawns wave animations every second.

rect is the bounding area. configuration includes fields like maxActiveWaves, which limit concurrency.

Implementation

void initParticles(Rect rect, WidgetSpoilerConfig configuration) {
  _config = configuration;

  // Call the base spoiler initialization (particles, fade, etc.).
  initializeParticles(Path()..addRect(rect), configuration);

  // Cancel any existing timer to avoid duplicates.
  _periodicWaveTimer?.cancel();

  // Every second, schedule three waves with random delays.
  _periodicWaveTimer = Timer.periodic(const Duration(seconds: 1), (_) {
    // Attempt to schedule 3 waves in quick succession:
    for (int i = 0; i < 3; i++) {
      _scheduleRandomWave();
    }
  });
}