advanced_haptics 1.0.0 copy "advanced_haptics: ^1.0.0" to clipboard
advanced_haptics: ^1.0.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.


# Advanced Haptics

A Flutter plugin for playing powerful, custom haptic feedback patterns. This package provides a unified API for Android and iOS, giving developers access to fine-grained vibration control and Apple Core Haptics `.ahap` files.

[![pub version](https://img.shields.io/pub/v/advanced_haptics.svg)](https://pub.dev/packages/advanced_haptics)
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

---

## âœĻ Features

- ✅ **Unified API** for Android and iOS
- ðŸŽŊ **Custom Waveforms**: Full control of timing and intensity
- 🍎 **Core Haptics on iOS**: Play `.ahap` files for rich tactile feedback
- 🧠 **Predefined Patterns**: Built-in methods like `lightTap()`, `successBuzz()`, `error()`, and more
- ðŸ›Ąïļ **Capability Detection**: Automatically detects device haptics support
- ðŸŠķ **Fallback Support**: Gracefully degrades on unsupported devices

---

## ðŸ–Ĩ Platform Support

| Feature               | Android 8.0+ | iOS 13.0+ (iPhone 8+) |
|-----------------------|--------------|------------------------|
| Waveform              | ✅ Native     | ✅ Emulated            |
| `.ahap` Playback      | 🔁 Fallback   | ✅ Native              |
| Amplitude Control     | ✅ Native     | ✅ Native              |
| Predefined Patterns   | ✅ Yes        | ✅ Yes                 |

> â„đïļ **Note:** iPads do not support Core Haptics. Use `hasCustomHapticsSupport()` to verify.

---

## 🚀 Getting Started

### 1. Install

```yaml
dependencies:
  advanced_haptics: ^0.0.1
flutter pub get

2. Android Setup #

Add the following permission to android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.VIBRATE"/>

3. iOS Setup #

Add your .ahap files under assets/haptics/, and include them in your pubspec.yaml:

flutter:
  assets:
    - assets/haptics/

Ensure your target device is an iPhone 8+ running iOS 13+.


ðŸŽĻ Example .ahap File (iOS only) #

{
  "Version": 1,
  "Pattern": [
    {
      "Event": {
        "Time": 0.0,
        "EventType": "HapticTransient",
        "EventParameters": [
          { "ParameterID": "HapticIntensity", "ParameterValue": 1.0 },
          { "ParameterID": "HapticSharpness", "ParameterValue": 1.0 }
        ]
      }
    }
  ]
}

Design .ahap files using Captain AHAP or manually.


ðŸ“Ķ Usage #

import 'package:advanced_haptics/advanced_haptics.dart';

✅ Check Support #

if (await AdvancedHaptics.hasCustomHapticsSupport()) {
  // Safe to use advanced feedback
}

⚡ Predefined Haptic Patterns #

await AdvancedHaptics.lightTap();
await AdvancedHaptics.mediumTap();
await AdvancedHaptics.heavyRumble();
await AdvancedHaptics.successBuzz();
await AdvancedHaptics.selectionClick();
await AdvancedHaptics.error();
await AdvancedHaptics.success();

🎛 Custom Waveform (Android preferred) #

await AdvancedHaptics.playWaveform(
  [0, 100, 150, 100],    // timings in ms
  [0, 180, 0, 255],      // amplitudes 0–255
);

🍏 Play .ahap (iOS only) #

await AdvancedHaptics.playAhap('assets/haptics/rumble.ahap');

🛑 Stop All Vibrations #

await AdvancedHaptics.stop();

🧠 API Reference #

Method Description
hasCustomHapticsSupport() Check platform and hardware support
playWaveform(timings, amplitudes) Custom vibration pattern (Android)
playAhap(path) Play an iOS .ahap haptic file
stop() Stop any ongoing vibration
success() Predefined double-tap haptic
lightTap({timings, amplitudes}) Quick subtle feedback
mediumTap({timings, amplitudes}) Mid-strength feedback
heavyRumble({timings, amplitudes}) Strong feedback
successBuzz({timings, amplitudes}) Buzz-buzz style success pattern
error({timings, amplitudes}) Alert/failure feedback
selectionClick({timings, amplitudes}) Crisp, click-like haptic

🙌 Contributing #

Pull requests and issues are welcome! Please test across devices and provide logs if possible.


📄 License #

This project is licensed under the MIT License. See LICENSE for full details.

2
likes
0
points
207
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for playing advanced, custom haptic feedback patterns on Android and iOS, including waveforms and Core Haptics .ahap files.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on advanced_haptics

Packages that implement advanced_haptics