vibration_composition 0.0.3 copy "vibration_composition: ^0.0.3" to clipboard
vibration_composition: ^0.0.3 copied to clipboard

A Plugin Forwarding (and Emulating) the Composition Haptics Api for Rich Vibrattions.

vibration_composition #

A plugin exposing Android's VibrationEffect.Composition API for rich, composable haptics.

  • Compose vibration patterns from named primitives (click, tick, thud, spin, ...).
  • Per-primitive scale and delay.
  • Query device capabilities before playing.

Platforms:

  • Android: forwards directly to the native composition API.
  • iOS: emulated on top of Core Haptics, exposed through the same API.

Usage #

See example/lib/main.dart for a full example.

Check support and prepare the vibrator:

import 'package:vibration_composition/vibration_composition.dart' as vib;

final supported = await vib.isCompositionSupported();
final available = await vib.supportedPrimitives();
await vib.prepareVibrator();

Play a composed pattern:

await vib.composeAndPlay([
  vib.CompositionParams(primitive: vib.Primitive.click),
  vib.CompositionParams(
    primitive: vib.Primitive.tick,
    scale: 0.6,
    delayMs: 100,
    delayType: vib.DelayType.afterEndOfPrev,
  ),
]);

API #

  • isCompositionSupported() - whether the device supports composition.
  • supportedPrimitives() - set of Primitives the device can play.
  • primitiveDurations() - map of Primitive to duration in ms.
  • composeAndPlay(pattern) - play a list of CompositionParams.
  • patternTargetDuration(pattern) - computed Duration of the pattern.
  • envelopeCapability() - envelope effect capabilities, or null.
  • prepareVibrator() - warm up the vibrator.

CompositionParams #

  • primitive - which Primitive to play.
  • scale - intensity, 0.0 - 1.0 (default 1.0).
  • delayMs - delay before this step (default 0).
  • delayType - afterEndOfPrev (default) or afterStartOfPrev.
0
likes
140
points
210
downloads

Documentation

API reference

Publisher

verified publisherh-h.win

Weekly Downloads

A Plugin Forwarding (and Emulating) the Composition Haptics Api for Rich Vibrattions.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, meta, plugin_platform_interface

More

Packages that depend on vibration_composition

Packages that implement vibration_composition