advanced_haptics 1.2.0
advanced_haptics: ^1.2.0 copied to clipboard
A Flutter plugin for playing advanced, custom haptic feedback patterns on Android and iOS, including waveforms and Core Haptics .ahap files.
Changelog #
All notable changes to advanced_haptics will be documented in this file.
1.2.0 #
- NEW: AGP 9 built-in Kotlin support, following Flutter's plugin migration guide. The Android build file no longer applies the Kotlin Gradle plugin (KGP) when AGP 9's built-in Kotlin is active (
android.builtInKotlin=true), configuresjvmTargetthrough thekotlin.compilerOptionsDSL, and declareskotlin-test-junit5explicitly for its unit tests (only KGP swaps a barekotlin-testfor the JUnit 5 variant). - Existing setups keep working unchanged: with built-in Kotlin disabled (what Flutter's templates write), Flutter 3.44+ applies KGP to plugin projects itself, and on older Flutter versions the plugin applies KGP as before. The minimum Flutter version is unchanged. Verified with Flutter 3.38.0 (AGP 8.11 / KGP 2.2.20), 3.44.8 (AGP 9.0.1, legacy mode) and 3.47.4 (AGP 9.1.0, built-in Kotlin).
- Enabling built-in Kotlin in an app needs Flutter 3.47 or newer: Flutter 3.44's tooling applies KGP to every plugin regardless of the setting, which AGP 9 rejects; 3.47 gates that on
android.builtInKotlin. Keep theorg.jetbrains.kotlin.android ... apply falsedeclaration (2.2.20+) insettings.gradle(.kts), since Flutter's version check reads it even though it is never applied. - The example app keeps Flutter's template defaults (
android.builtInKotlin=false); the README explains how to switch.
1.1.0 #
Design one pattern, play it everywhere.
- NEW:
HapticPattern,HapticTransient,HapticContinuousandHapticPatternBuilder: a platform-independent pattern model with intensity and sharpness per event.AdvancedHaptics.playPattern()renders it as Core Haptics events on iOS, asVibrationEffect.Compositionprimitives on Android 11+ (tap-only patterns,TICK/CLICK/THUDchosen by sharpness), and as a waveform everywhere else.HapticPattern.toWaveform()exposes the flattening for callers who want the raw waveform. - NEW:
AndroidHapticPrimitive,AndroidPrimitiveEventandAdvancedHaptics.playComposition(): direct access to Android's composition primitives (click,tick,thud,spin,quickRise,slowRise,quickFall,lowTick). Unsupported devices and Android below API 30 get a waveform approximation; iOS renders the closest Core Haptics events, so the call is safe on every platform. - NEW:
AdvancedHaptics.supportsAndroidPrimitives()reports native primitive support (API 30+ and hardware). - Compositions and predefined effects cannot be paused; patterns played as waveforms or Core Haptics can.
1.0.10 #
- CHORE: Bumped
flutter_lintsto^6.0.0(dev dependency only; no runtime changes). The package and example analyze cleanly under the current lint set.
1.0.9 #
Robustness release: every method is now safe to call on any platform and device.
- FIX:
AndroidPredefinedHapticused wrong effect IDs (pop/thud/ringtone1mapped to ringtone effects). IDs now matchandroid.os.VibrationEffect; addedtextureTick. Unsupported effects fall back toclick(API 30+). - FIX:
cancel(),pause(),resume()andseek()threwMissingPluginExceptionon Android. - NEW:
pause(),resume()andseek()now work on Android. The vibrator has no native pause, so the plugin tracks the position inside the playing waveform, cancels on pause and replays the remainder (looping included) on resume or seek.PLAYER_NILis thrown when nothing is playing, matching iOS. - FIX:
stop()andcancel()on iOS threwPLAYER_NILwhen nothing was playing. They are now idempotent. - FIX:
atTimeon iOS was passed as an absolute engine time, so scheduled playback/pause/resume/stop never worked. It is now a delay in seconds from now. - FIX: iOS devices without Core Haptics (iPads, iPhone 7 and older) threw
UNSUPPORTEDon every call. They now fall back toUIFeedbackGenerator. - FIX: iOS engine reset/stop handlers mutated state off the main thread, and a stale player could block new playback after an engine reset.
- FIX: Repeating waveforms on iOS ignored trailing silence (
loopEndwas never set). - FIX: Android crashed with
ClassCastExceptionwhen timings exceeded 32 bits, andSecurityException(missingVIBRATEpermission) was not caught. - FIX:
hasCustomHapticsSupport()could throw on platforms without a native implementation or when the native side returnednull. - NEW:
playWaveform(repeat: ...)is now a real parameter (it was documented but ignored). - NEW: Dart-side argument validation with clear
ArgumentErrors (empty lists, mismatched lengths, negative timings, amplitudes outside 0-255, badrepeat, negative times). - NEW: Android below API 26 plays the on/off shape of a waveform (previously a fixed 200 ms buzz);
playPredefinedplays an approximation below API 29 instead of erroring. UsesVibratorManageron API 31+. - NEW: Very short iOS waveform segments (< 40 ms) are rendered as transient taps, which are far more perceptible.
- NEW:
playAhapaccepts absolute file paths in addition to Flutter asset paths. - NEW:
AdvancedHapticsPlatformis now a real platform interface: replaceAdvancedHapticsPlatform.instancewith a mock in tests. - NEW: iOS sources ship as a Swift package (
ios/advanced_haptics/Package.swift) with a privacy manifest, so apps built with Swift Package Manager (default since Flutter 3.44) no longer fall back to CocoaPods. The podspec is kept for CocoaPods users. - CHORE: Real Dart and Kotlin unit tests; podspec metadata; plugin
build.gradlemoved to Java 17 /compileSdk 36and no longer double-applies the Kotlin plugin under AGP 9. - CHORE: Example app modernised: Gradle 9.1 / AGP 9.0.1 / Kotlin 2.3.20 (it could not build on the JDK current Flutter uses), iOS deployment target 13.0 (the podspec minimum), error reporting in the UI, demos for looping waveforms, predefined effects and player controls.
1.0.8 #
Updated ReadMe
1.0.7 #
Contributor: @rdeekshitha-scapia — #4
- FIX: Lowered
minSdkVersionfrom 26 to 21, allowing the plugin to be used in apps targeting Android 5.0+. API 26 (Oreo) haptic requirements are now enforced at runtime via a centralizedhasOreoHaptics()check rather than at the build level.
1.0.6 #
1.0.5 #
- FIX: Resolved a build error on iOS versions below 16 caused by use of
CHHapticPattern(contentsOf:), which is only available in iOS 16+. Implemented a fallback using manual AHAP JSON decoding andCHHapticPattern(dictionary:)for compatibility with iOS 13–15.
1.0.4 #
- Updated README.
1.0.3 #
- Added platform-specific methods for iOS.
- Improved README structure and organization.
1.0.2 #
- Added platform-specific methods for Android.
1.0.1 #
- Updated README.
1.0.0 #
- Proper launch of
advanced_haptics.
0.0.6 #
- FIX: Resolved a build error on iOS (
Cannot find type 'CHHapticPlayer' in scope) by adding the necessaryCoreHapticsframework import.
0.0.5 #
- Fixed playback issues on iOS in the
waveformmethod.
0.0.4 #
- Fixed playback issues on iOS in the
waveformmethod.
0.0.3 #
- Fixed bug in iOS.
0.0.2 #
- Updated README.
0.0.1 #
- Initial release of the
advanced_hapticspackage. - Support for Android waveform patterns.
- Support for iOS Core Haptics via
.ahapfiles. - Added predefined patterns and device support checking.