Coder Social home page Coder Social logo

yxwandroid / flutter_vibration Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benjamindean/flutter_vibration

0.0 1.0 0.0 89 KB

Handle vibration on iOS and Android in Flutter apps

License: BSD 2-Clause "Simplified" License

Java 25.04% Ruby 24.57% Swift 10.60% Objective-C 3.01% Dart 36.78%

flutter_vibration's Introduction

Vibration

Build Status

A plugin for handling Vibration API on iOS and Android devices. API docs.

Getting Started

  1. Add vibration to the dependencies section of pubspec.yaml.

    dependencies:
      vibration: 1.1.0
  2. Import package:

    import 'package:vibration/vibration.dart';

Methods

hasVibrator

Check if the target device has vibration capabilities.

if (Vibration.hasVibrator()) {
    Vibration.vibrate();
}

vibrate

With specific duration (for example, 1 second):

Vibration.vibrate(duration: 1000);

Default duration is 500ms.

With pattern (wait 500ms, vibrate 1s, waint 500ms):

Vibration.vibrate(pattern: [500, 1000, 500]);

cancel

Stop ongoing vibration.

Vibration.cancel();

Android

The VIBRATE permission is required in AndroidManifest.xml.

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

Supports vibration with duration and pattern. On Android 8 (Oreo) and above, uses the VibrationEffect class. For the rest of the usage instructions, see Vibrator class documentation.

iOS

Only supports singular vibrations with 500ms duration.

flutter_vibration's People

Contributors

benjamindean avatar eddydpyl avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.