vibration Flutter Plugin

repository·master·Indexed 43 days ago

https://github.com/benjamindean/flutter_vibration

A Flutter plugin providing cross-platform vibration capabilities for iOS, Android, Web, and OpenHarmony. It offers a unified API to trigger haptic feedback using durations, custom patterns, intensities, and predefined VibrationPreset values. Includes specialized support for OpenHarmony via the vibration_ohos package, allowing for VibrateEffect and VibrateAttribute configurations.

Tokens
3.8K
Snippets
22
Records
26
Agent score
54%

What's inside vibration

  1. Customize iOS launch screen assets

    master

    To customize the iOS launch screen, you can either replace the image files directly in the vibration/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/ directory or use Xcode for a more visual approach.

    Using Xcode:

    1. Open the iOS workspace using the command: open ios/Runner.xcworkspace.
    2. In the Xcode Project Navigator, navigate to Runner/Assets.xcassets.
    3. Drag and drop your desired images into the asset catalog to replace the existing launch screen assets.
    open ios/Runner.xcworkspace
  2. Use the web implementation of vibration

    master

    To use vibration on the web, ensure you have the vibration package added to your pubspec.yaml. Once added, you can use package:vibration as you would in a standard Flutter project. This package provides the web-specific implementation required for the vibration plugin to function in a browser environment.

    dependencies:
      vibration: ^latest_version
  3. Use vibration on OpenHarmony

    master

    When using the OpenHarmony implementation (vibration_ohos), you can access vibrateEffect and vibrateAttribute by casting the platform instance to VibrationOhos.

    (VibrationPlatform.instance as VibrationOhos).vibrate(
      vibrateEffect: const VibratePreset(count: 100),
      vibrateAttribute: const VibrateAttribute(
        usage: 'alarm',
      ),
    );