ConfettiWidget class

A widget that renders a confetti animation within its own bounds.

Place inside a Stack to overlay confetti on top of your content, or constrain it to any region you like.

For a zero-configuration full-screen experience use ConfettiEngine.celebrate instead.

With autoPlay:

Stack(children: [
  YourContent(),
  ConfettiWidget(preset: Preset.nova),
])

With a manual controller:

final _ctrl = ConfettiController();

ConfettiWidget(
  preset: Preset.cascade,
  controller: _ctrl,
  autoPlay: false,
)

// Later:
_ctrl.play();

Driving haptics and sound from app state:

ConfettiWidget(
  preset: Preset.nova,
  feedback: CelebrationFeedback(
    enableHaptics: settings.hapticsOn,
    enableSound: settings.soundOn,
    soundAssetPath: 'assets/sounds/cheer.mp3',
  ),
)

Custom emoji pool for unicode particles:

ConfettiWidget(
  preset: Preset.nova,
  emojiPool: const ['🎮', '🏆', '💎'],
)
Inheritance

Constructors

ConfettiWidget({Key? key, Preset preset = Preset.nova, ConfettiController? controller, bool autoPlay = true, VoidCallback? onComplete, bool enableHaptics = true, bool enableSound = false, String? soundAssetPath, CelebrationFeedback? feedback, List<String>? emojiPool, ConfettiCustomization? customization, ConfettiShowcase? showcase})
Creates a ConfettiWidget.
const

Properties

autoPlay bool
Whether to start the animation immediately after the first layout.
final
controller ConfettiController?
Optional controller for programmatic play/stop/reset.
final
customization ConfettiCustomization?
Optional overrides for count, colors, shapes, gravity, and scaling.
final
emojiPool List<String>?
Characters to randomly assign to ParticleShape.emoji particles.
final
enableHaptics bool
Whether to fire HapticFeedback at animation start. Defaults to true.
final
enableSound bool
Whether to play audio when the animation starts. Defaults to false.
final
feedback CelebrationFeedback?
Optional grouped haptic and audio settings.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onComplete VoidCallback?
Called once when all particles have faded and the animation is complete.
final
preset Preset
The animation style to use. Defaults to Preset.nova.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showcase ConfettiShowcase?
When non-null, uses ShowcaseParticleFactory tick bursts (preset is ignored for spawn).
final
soundAssetPath String?
Flutter asset path for the sound file (e.g. 'assets/sounds/cheer.mp3').
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<ConfettiWidget>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited