native_haptics_and_audio 2.0.0 copy "native_haptics_and_audio: ^2.0.0" to clipboard
native_haptics_and_audio: ^2.0.0 copied to clipboard

Ultra-low latency native haptic and audio feedback designed specifically for high-speed performance on iOS and Android.

2.0.0 #

A major overhaul of the plugin core with selective audio loading, custom sound asset support, per-play volume/rate controls, and an expanded sound catalog.

Breaking Changes #

  • Enums renamed: PosSoundNativeSound, PosHapticHapticPattern (deprecated aliases provided for 1.x compatibility).
  • playSound()play(): Now accepts volume and rate and returns a Future. playSound() remains as a deprecated alias.
  • Lazy loading: initialize() no longer preloads all audio. Sounds load on-demand via play() or upfront via preload() / preloadAll().
  • iOS silent-switch behavior: Now configurable via respectSilentSwitch (defaults to true).
  • Minimum SDK constraints: Updated to Flutter >=3.41.0 / Dart >=3.11.

New Features #

  • Custom sounds: Play any host app or package asset via CustomSound('assets/sfx/sound.m4a').
  • Catalog expanded to 13 sounds: Added appError, paymentSuccess, deviceConnected, buzzerError, errorChime, walletConfirm, nfcSuccess, softSuccess, and transactionSuccess.
  • Audio control: Added per-play volume, playback rate, and simultaneous maxStreams configuration.
  • Memory management: Added LRU cache management and pinning APIs (preload(), preloadAll(), unload(), unloadAll(), isLoaded(), pinnedAssets, cachedAssets).
  • Asset verification & error resilience: preload() returns Future<bool> to verify asset integrity at startup, with automatic load timeouts and unsupported format warnings.

Improvements & Fixes #

  • iOS backend rewrite: Migrated from AudioServices to AVAudioEngine with cached haptic generators and audio interruption handling.
  • Package size reduction: Converted bundled sounds to .m4a format (~90% size reduction).
  • Android build compatibility: Resolved Kotlin and AGP 8/9 build compatibility issues.
  • Stability fixes: Fixed SoundPool lifecycle leaks, concurrent load matching by sampleId, and in-flight load cleanup on release().
  • Privacy manifest: Included PrivacyInfo.xcprivacy in Package.swift for SwiftPM builds.

1.1.0 #

Ecosystem & Modernization Migrations #

  • iOS Swift Package Manager (SwiftPM): Fully migrated iOS platform code to the official SwiftPM layout (ios/native_haptics_and_audio/Package.swift) while maintaining dual-mode CocoaPods compatibility. Configured explicit FlutterFramework dependency and asset loading for Flutter 3.27+.
  • Android Built-in Kotlin: Removed legacy Kotlin Gradle Plugin (KGP) dependencies from build.gradle.kts in alignment with Flutter's "Built-in Kotlin" initiative and cleaned up redundant source set definitions.

Concurrency & Stability Fixes #

  • Dart Initialization Race Condition: Hardened NativeHapticsAndAudioRepository.initialize() using Future<void>? caching. Concurrent callers now wait for the active initialization to complete instead of risking in-flight execution races.
  • Android SoundPool Callback Guard: Protected SoundPool.setOnLoadCompleteListener with an AtomicBoolean to guarantee the Pigeon Result callback is invoked exactly once regardless of asynchronous multi-asset load callbacks.

Developer Experience & Testing #

  • Testing Reset Hook: Added @visibleForTesting NativeHapticsAndAudioRepository.resetForTesting() to facilitate test isolation in consuming applications and plugin tests.
  • Native Android Unit Tests: Added JUnit 4 test suite with Mockito to verify native haptic motor triggers and waveform pattern dispatches.
  • Strict Static Analysis: Enabled strict-casts and strict-inference in analysis_options.yaml.

1.0.1 #

  • Fix pub.dev description length warning for improved SEO scoring.

1.0.0 #

  • Initial release.
  • Added zero-latency 16-bit PCM mono audio playback for scannerBeep, warningBeep, doubleWarningBeep, and kaching.
  • Added ultra-low latency hardware haptic feedback for success (crisp UI impact), warning, and error.
  • Implemented graceful fallback logic to prevent runtime crashes on unsupported desktop and web platforms.
3
likes
160
points
146
downloads

Documentation

API reference

Publisher

verified publisherandresmontano.dev

Weekly Downloads

Ultra-low latency native haptic and audio feedback designed specifically for high-speed performance on iOS and Android.

Repository (GitHub)
View/report issues

Topics

#haptics #audio #pos #barcode-scanner #native

License

MIT (license)

Dependencies

flutter, meta

More

Packages that depend on native_haptics_and_audio

Packages that implement native_haptics_and_audio