initializeParticles method

  1. @override
void initializeParticles(
  1. Path path,
  2. SpoilerConfig configuration, {
  3. List<Rect>? rects,
})
override

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

path defines the spoiler area. configuration includes fields like WidgetSpoilerConfig.maxActiveWaves, which limit concurrency. rects optionally provide per-line bounds.

Implementation

@override
void initializeParticles(Path path, SpoilerConfig configuration,
    {List<Rect>? rects}) {
  if (configuration is WidgetSpoilerConfig) {
    _config = configuration;
  }

  // Call the base spoiler initialization (particles, fade, etc.).
  super.initializeParticles(path, configuration, rects: rects);

  // 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();
    }
  });
}