flutter_confetti_engine library
flutter_confetti_engine
A celebration package that combines confetti particle animation, haptic feedback, and optional sound in a single API call.
Quick start:
import 'package:flutter_confetti_engine/flutter_confetti_engine.dart';
// One-liner — full-screen burst with haptics:
ConfettiEngine.celebrate(context);
// With a preset:
ConfettiEngine.celebrate(context, preset: Preset.nova);
// Stock clip for the preset you pass to celebrate():
ConfettiEngine.celebrate(
context,
preset: Preset.cascade,
feedback: CelebrationFeedback.bundledForPreset(Preset.cascade),
);
// Your own asset + toggle haptics/sound:
ConfettiEngine.celebrate(
context,
feedback: CelebrationFeedback.customAsset(
'assets/party.mp3',
enableHaptics: true,
enableSound: true,
),
);
// Message banner + max duration (overlay closes at 3s or when particles end):
ConfettiEngine.celebrate(
context,
overlayMessage: CelebrationMessageOptions.withDefaults(
'Congratulations! 🎉',
durationInSeconds: 3,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Color(0x88000000),
borderRadius: BorderRadius.all(Radius.circular(16)),
),
),
);
// Manual control:
final controller = ConfettiController();
ConfettiWidget(preset: Preset.flare, controller: controller, autoPlay: false)
controller.play();
Classes
- CelebrationFeedback
- Groups haptic and audio settings for ConfettiWidget and ConfettiEngine.
- CelebrationMessageOptions
- Text banner layered over full-screen particle celebration.
- CelebrationScene
- Bundles a Preset with optional defaults — semantic types (ConfettiType), color themes (ConfettiColorTheme), or your own ConfettiCustomization.
- ConfettiAnimationMaps
- Maps AnimationConfetti to Preset and optional ConfettiCustomization.
- ConfettiBundledSounds
- Helpers for the 10 audio clips shipped with this package.
- ConfettiColorThemes
- Resolves ConfettiColorTheme to concrete Color lists for ConfettiCustomization.colors.
- ConfettiController
- Drives a ConfettiWidget manually.
- ConfettiCustomization
- Optional overrides for particle count, colors, shape mix, physics, and directional cone (burstDirectionDegrees) for applicable presets.
- ConfettiDensityScale
- Scales default particle counts for ConfettiDensity.
- ConfettiEngine
- The primary entry point for flutter_confetti_engine.
- ConfettiStyleShapes
- Resolves ConfettiStyle to ConfettiCustomization.shapeMix entries.
- ConfettiWidget
- A widget that renders a confetti animation within its own bounds.
- ShowcaseParticleFactory
-
Builds particle lists for ConfettiShowcase using
TickConfettiPhysics. - TickConfettiSpawnOptions
- Spawn parameters for tick mode — angle / spread cone, velocity decay, gravity, drift, tick lifespan, and scalar.
Enums
- AnimationConfetti
- Animation motion profiles for mapped presets.
- BuiltinSound
- Built-in synthesized audio clips shipped with flutter_confetti_engine.
- ConfettiColorTheme
- Named palettes for themed celebration scenes.
- ConfettiDensity
- Particle amount relative to each Preset’s default count.
- ConfettiShowcase
- Eight curated tick bursts for showcase scenarios (basic cannon, random direction, dualLaunch, starField, emojiPop, school pride, manual launch/kill, bounded emitter).
- ConfettiStyle
- High-level particle appearance presets.
- ConfettiType
- Semantic party outcome categories.
- ControllerState
- The state of a ConfettiController.
- ParticleShape
- The visual shape rendered for each confetti particle.
- Preset
- Built-in animation presets — curated factory layouts (“nova”, “cascade”, “flare”, “crossfire”).
Constants
-
kDefaultCelebrationEmojis
→ const List<
String> - Default unicode strings used for ParticleShape.emoji particles when particles are created without a custom emoji list (see ConfettiWidget.emojiPool).
-
kTickConfettiPackageColors
→ const List<
Color> - Default palette for tick mode — cyan / violet / pink / yellow / orange / magenta.
-
kTickConfettiWarmPalette
→ const List<
Color> - Warm accent palette for tick-mode showcases.