native_haptics_and_audio 2.0.0
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:
PosSound→NativeSound,PosHaptic→HapticPattern(deprecated aliases provided for 1.x compatibility). playSound()→play(): Now acceptsvolumeandrateand returns aFuture.playSound()remains as a deprecated alias.- Lazy loading:
initialize()no longer preloads all audio. Sounds load on-demand viaplay()or upfront viapreload()/preloadAll(). - iOS silent-switch behavior: Now configurable via
respectSilentSwitch(defaults totrue). - 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, andtransactionSuccess. - Audio control: Added per-play
volume, playbackrate, and simultaneousmaxStreamsconfiguration. - Memory management: Added LRU cache management and pinning APIs (
preload(),preloadAll(),unload(),unloadAll(),isLoaded(),pinnedAssets,cachedAssets). - Asset verification & error resilience:
preload()returnsFuture<bool>to verify asset integrity at startup, with automatic load timeouts and unsupported format warnings.
Improvements & Fixes #
- iOS backend rewrite: Migrated from
AudioServicestoAVAudioEnginewith cached haptic generators and audio interruption handling. - Package size reduction: Converted bundled sounds to
.m4aformat (~90% size reduction). - Android build compatibility: Resolved Kotlin and AGP 8/9 build compatibility issues.
- Stability fixes: Fixed
SoundPoollifecycle leaks, concurrent load matching bysampleId, and in-flight load cleanup onrelease(). - Privacy manifest: Included
PrivacyInfo.xcprivacyinPackage.swiftfor 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 explicitFlutterFrameworkdependency and asset loading for Flutter 3.27+. - Android Built-in Kotlin: Removed legacy Kotlin Gradle Plugin (KGP) dependencies from
build.gradle.ktsin 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()usingFuture<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.setOnLoadCompleteListenerwith anAtomicBooleanto guarantee the PigeonResultcallback is invoked exactly once regardless of asynchronous multi-asset load callbacks.
Developer Experience & Testing #
- Testing Reset Hook: Added
@visibleForTestingNativeHapticsAndAudioRepository.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-castsandstrict-inferenceinanalysis_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, andkaching. - Added ultra-low latency hardware haptic feedback for
success(crisp UI impact),warning, anderror. - Implemented graceful fallback logic to prevent runtime crashes on unsupported desktop and web platforms.