CelebrationFeedback class
Groups haptic and audio settings for ConfettiWidget and ConfettiEngine.
Sound — three approaches, pick one per celebration:
- Built-in clip — set builtinSound to BuiltinSound.pop or
BuiltinSound.chime. No extra
pubspec.yamlsetup required. - Preset-matched clip — use the bundledForPreset factory and the package chooses the right built-in automatically.
- Your own file — register an asset in your app's
pubspec.yamland pass its path via soundAssetPath or the customAsset factory.
When both builtinSound and soundAssetPath are set, soundAssetPath takes priority. Only one should be set at a time.
Toggles — enableSound and enableHaptics are independent. When enableSound is false, all sound fields are ignored.
Use this object to drive feedback from app state or user preferences without threading multiple booleans through every call site.
- Annotations
Constructors
- CelebrationFeedback({bool enableHaptics = true, bool enableSound = false, BuiltinSound? builtinSound, String? soundAssetPath})
-
Creates feedback settings.
const
- CelebrationFeedback.bundledForPreset(Preset preset, {bool enableHaptics = true, bool enableSound = true})
-
Plays the BuiltinSound best matched to
preset.factory - CelebrationFeedback.customAsset(String soundAssetPath, {bool enableHaptics = true, bool enableSound = true})
-
Your own audio file (path from your app's
flutter: assets:list).factory - CelebrationFeedback.hapticsOnly()
-
Preset-specific haptics only; no audio.
const
- CelebrationFeedback.none()
-
No platform haptics and no audio.
const
Properties
- builtinSound → BuiltinSound?
-
A built-in synthesized clip shipped with the package.
final
- enableHaptics → bool
-
Whether to fire HapticFeedback at animation start.
final
- enableSound → bool
-
Whether to play audio when the animation starts.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- resolvedSoundPath → String?
-
The asset path that will actually be played.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- soundAssetPath → String?
-
Flutter asset path for a custom sound (e.g.
'assets/sounds/cheer.mp3').final
Methods
-
copyWith(
{bool? enableHaptics, bool? enableSound, BuiltinSound? builtinSound, String? soundAssetPath}) → CelebrationFeedback - Returns a copy with the given fields replaced.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited