Giter Club home page Giter Club logo

flutter_vibration's Introduction

flutter_vibration's People

Contributors

asaarnak avatar benjamindean avatar creativecreatorormaybenot avatar dkrutskikh avatar eddydpyl avatar filiponesco avatar hugoheneault avatar leicas avatar nrawut avatar pmundt avatar roulljdh avatar san-smith avatar skyost avatar stevejob avatar tanaysinghal avatar wanghaiyang5241 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flutter_vibration's Issues

Add a `supportCustomVibrations` method

Hey.

I love the latest plugin update that added the CoreHaptics support. Would it be possible for you to create a method (can be named supportCustomVibrations or whatever) which would return :

  • true on Android.
  • true on CoreHaptics iOS devices (and false on older devices).

This way, we could have a better control on which devices we can play custom vibrations, and on which devices it's not possible to do so.

Thanks !

Vibration not work on my device (Android version 9 / Pie)

Steps to Reproduce

  1. Add vibration: ^1.2.4 to pubspec.yaml.

  2. Add permission on the AndroidManifest.xml (main)

  3. Add an example like below:

import 'package:flutter/material.dart';
import 'package:vibration/vibration.dart';

void main() => runApp(VibratingApp());

class VibratingApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Vibration Plugin example app'),
          ),
          body: Builder(builder: (BuildContext context) {
            return Center(
              child: Column(
                children: <Widget>[
                  RaisedButton(
                    child: Text('Vibrate for default 500ms'),
                    onPressed: () {
                      Vibration.vibrate();
                    },
                  ),
                  RaisedButton(
                    child: Text('Vibrate for 1000ms'),
                    onPressed: () {
                      Vibration.vibrate(duration: 1000);
                    },
                  ),
                  RaisedButton(
                    child: Text('Vibrate with pattern'),
                    onPressed: () {
                      final snackBar = SnackBar(
                        content: Text(
                            'Pattern: wait 0.5s, vibrate 1s, wait 0.5s, vibrate 2s, wait 0.5s, vibrate 3s, wait 0.5s, vibrate 0.5s'),
                      );

                      Scaffold.of(context).showSnackBar(snackBar);
                      Vibration.vibrate(
                          pattern: [500, 1000, 500, 2000, 500, 3000, 500, 500]);
                    },
                  )
                ],
              ),
            );
          })),
    );
  }
}
  1. Run the Apps (But vibration not working on my device)
  2. Here my flutter doctor result
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.2 19C57,
    locale en-US)
    • Flutter version 1.12.13+hotfix.8 at
      /Users/rrifafauzikomara/Documents/flutter
    • Framework revision 0b8abb4724 (3 months ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/rrifafauzikomara/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling
      support)
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.39.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.5.1

[✓] Connected device (1 available)
    • SM A600G • 5200e3e7f01e45f3 • android-arm • Android 9 (API 28)

• No issues found!

Widget tests on vibration plugin

what is the name for MethodChannel ? I used following package name in widget tests with no success:

MethodChannel channel =
      const MethodChannel('com.benjaminabel.vibration');
  channel.setMockMethodCallHandler((MethodCall methodCall) async {
    print("=============>>>>> $methodCall  <<<<<===================");
  });

Haptic vibration not supported on iphone 7

Hi,

I have :

  • An iphone 7 with ios 13.3.1
  • Enabled haptic in the settings

await Vibration.hasCustomVibrationsSupport()) --> returns false --> i can't use the haptic feature.

2 questions:

  1. On which device have you tested ?

  2. are you supporting ios 14 ?

thx.

bool operator for hasVibrator

i get an error when i try this:

               if (Vibration.hasVibrator()) {
				Vibration.vibrate(duration: 500);
				return true;
		}

saying

Conditions must have a static type of 'bool'.
Try changing the condition.

Amplitude isn't controlled in iOS

Even if hasAmplitudeControl() returns true in iOS, calling vibrate() with a custom amplitude parameter doesn't variate the amplitude of the generated vibration. On Android it works correctly

Tested with

Flutter 2.2.1
Vibration 1.7.3
iPhone 6S with iOS 14.5.1, the only one that I have

Vibration.cancel() doesn't work on iOS

I have vibration turned on with a pattern but in some cases I want the vibration to stop earlier, so I use Vibration.cancel().
On android it works great but on iOS it seems to continue to vibrate until the pattern is done.

swift 5 conversion on ios

hello, i'm getting a warning about swift 5 conversion on ios, anything i can do to get rid of that message?

i'm using v 1.2.2.

Thanks.

Vibration not working in first few calls

I tried to add this plugin to my app, and tested another one. Both had the same issue on iOS and web.

I basically made it vibrate when clicking a button. On few first clicks, nothing happens, but then suddenly the vibration works.

What could be the issue? I'm just calling Vibration.vibrate(), not even bothering with the custom duration overload, and not waiting for anything, it's just that function

HasVibrator does not work

My visual code is causing an error when I put this method (has) in my code.
Can you give me a hand?

import 'package:flutter/material.dart';
import 'package:vibration/vibration.dart';

void main() => runApp(Home());

class Home extends StatelessWidget {
  const Home({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter Flutter",
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.red,
          title: Text("Flutter vibrate"),
        ),
        body: Body(),
      ),
    );
  }
}

class Body extends StatefulWidget {
  @override
  _BodyState createState() => _BodyState();
}


class _BodyState extends State<Body> {
  void vibrate() {
    if(Vibration.hasVibrator()){
      Vibration.vibrate();
    }
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: FlatButton(
        onPressed: vibrate,
        child: Text("Click to vibrate"),
      )
    );
  }
}`

Depends on flutter_test

Hi,

Does this plugin have to depend on flutter_test ? Flutter_test depends on an old version of the image plugin, which I now can't upgrade because this vibration plugin depends on flutter_test.

Because no versions of vibration match >1.2.3 <2.0.0 and vibration 1.2.3 depends on flutter_test any from sdk, vibration ^1.2.3 requires flutter_test any from sdk.

And because every version of flutter_test from sdk depends on image 2.1.4, vibration ^1.2.3 requires image 2.1.4.

It seem doesn't work

Here is my code:

	void _submmit() async {
		if (await Vibration.hasVibrator()) {
			print("111");
			Vibration.vibrate(duration: 500);
			if (await Vibration.hasAmplitudeControl()) {
				Vibration.vibrate(amplitude: 128);
			}
		} else {
			print("222");
		}
	}

The log printed "111",but the phone didn't vibrate.
My phone is :iPhone 7
IOS: 13.3.1

how to use intensifies

i want just to vibrate for a few seconds and all this time that it intensifies friom 1 to 255, or rather, reversely, goes from 255 to 1
from you readme i thought that to perform that i'm supposed to do just that

Vibration.vibrate(
  duration: duration,
  intensities: reverse ? const [255, 1] : const [1, 255],
);

but it doesn't seem to work and that's confusing

upd: testing on iphone x

Vibration.hasVibrator() promise false in iOS

‍‍‍Vibration.hasVibrator() in iOS always promis false.
I've checked swift code and you get the value of hasVibrator from TARGET_OS_SIMULATOR == 1 and then this code always returns false in physical iOS device.
What's wrong?

uri=org-dartlang-untranslatable-uri:package%3Avibration%2Fvibration.dart

while try to make a iOS build it crash due to this error-->
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:package%3Avibration%2Fvibration.dart; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1 asFileUri (package:vm/kernel_front_end.dart:623:37)
#2 writeDepfile (package:vm/kernel_front_end.dart:763:21)

#3 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:586:9)

#4 starter (package:flutter_frontend_server/server.dart:85:12)

#5 main (file:///opt/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:13:24)

Failed to package /Users/appledev/Desktop/flutter/flutterClient.

Vibration is not working on Android 10

Vibration is not working for Android 10

I have already added below the line in my AndroidManifest.xml:
<uses-permission android:name="android.permission.VIBRATE"/>

Code for Vibration:

if (Vibration.hasVibrator() != null) {
     if (Vibration.hasAmplitudeControl() != null) {
          Vibration.vibrate(duration: 500,amplitude: 128,);
      } else {
          Vibration.vibrate();
      }
}

In case of Android 10 hasAmplitudeControl condition is satisfied and also there is no error but still, the device is not vibrating.

Depricated warning

I am getting this warning when I run flutter:

Note: /usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/vibration-1.2.1/android/src/main/java/com/benjaminabel/vibration/VibrationPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

How to set the vibration for one hr

How can i set the interval of vibration for more than hrs,
eg:
RaisedButton(
child: Text('Vibrate for 1000ms'),
onPressed: () {
Vibration.vibrate(duration: 100000, repeat: 90000000);
},
),

how can i set it for hrs?
or vibrate untill we tap Vibration.cancel();

1.7.4-nullsafety.0 vibration problems on ios

during development of my app i pass qa on these devices and then on relese just bumped the version from 1.7.3 to 1.7.4-nullsafety.0

after app released i received a feedback that vibration is not working on these devices:

  • iPhone X
  • iPhone SE 2020

is it possible that there were any changes that might have broken the plugin for these?

EXC_BAD_ACCESS on iPhone SE since 1.3.0

Hi there! THanks for your cool vibration plugin 👍

My app won't load on iPhone SE simulator since 1.3.0 update.

I have an EXC_BAD_ACCESS error. Working on a PR. :-)

Example wrong?

In the README there is the following example code:

Vibration.vibrate(pattern: [500, 1000, 500, 2000], intensities: [1, 255]);

It doesn't seem to be working on Android:

E/MethodChannel#vibration(10881): Failed to handle method call
E/MethodChannel#vibration(10881): java.lang.IllegalArgumentException: timing and amplitude arrays must be of equal length (timings.length=4, amplitudes.length=2)
E/MethodChannel#vibration(10881): 	at android.os.VibrationEffect$Waveform.validate(VibrationEffect.java:635)
E/MethodChannel#vibration(10881): 	at android.os.VibrationEffect.createWaveform(VibrationEffect.java:244)
E/MethodChannel#vibration(10881): 	at com.benjaminabel.vibration.Vibration.vibrate(Vibration.java:74)
E/MethodChannel#vibration(10881): 	at com.benjaminabel.vibration.VibrationMethodChannelHandler.onMethodCall(VibrationMethodChannelHandler.java:48)
E/MethodChannel#vibration(10881): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#vibration(10881): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#vibration(10881): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:738)
E/MethodChannel#vibration(10881): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#vibration(10881): 	at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#vibration(10881): 	at android.os.Looper.loop(Looper.java:183)
E/MethodChannel#vibration(10881): 	at android.app.ActivityThread.main(ActivityThread.java:7660)
E/MethodChannel#vibration(10881): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#vibration(10881): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#vibration(10881): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

It also doesn't make much sense to set intensity for the time between vibrations.

iOS build fails: fatal error: 'vibration/vibration-Swift.h' file not found

When I run my application for iOS it fails with this error.

flutter/.pub-cache/hosted/pub.dartlang.org/vibration-1.4.0/ios/Classes/VibrationPlugin.m:2:9: fatal error: 'vibration/vibration-Swift.h' file not found #import <vibration/vibration-Swift.h>

Anyone who can help me to resolve this error?

Thread 1: EXC_BAD_ACCESS Error when debug

I am checking whether this plugin works in ios.
so I wrote really simple flutter like following:

import 'package:vibration/vibration.dart';

//...

void _vibrate() {
     Vibration.vibrate();
  }

//  ...

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'vibration test',
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: ()=> _vibrate(),
        tooltip: 'vibrate',
        child: Icon(Icons.vibration),
      ), 
    );
  }

when I debug it in Xcode, I got following result in VibrationPlugin.m:
Thread 1: EXC_BAD_ACCESS (code=2, address=0x16b627fe0)
and several [VibrationPlugin registerWithRegistrar:registrar] object on the left window.

Does somebody know what is the reason of it?
After spending long time of research I guess it could be stack overflow problem.
but I don't know why it occurs.

replay

if i set [500, 1000, 500, 2000, 500, 3000, 500, 100] this pattern and vibration run continue when user not stop them what i do?

Also how i speed the vibration?

java.lang.IllegalArgumentException: timing and amplitude arrays must be of equal length (timings.length=4, amplitudes.length=2)

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: PlatformException(error, timing and amplitude arrays must be of equal length (timings.length=4, amplitudes.length=2), null, java.lang.IllegalArgumentException: timing and amplitude arrays must be of equal length (timings.length=4, amplitudes.length=2)
	at android.os.VibrationEffect.createWaveform(VibrationEffect.java:256)
	at d.d.a.a.d(Unknown Source:74)
	at d.d.a.b.onMethodCall(Unknown Source:147)
	at f.a.c.a.j$a.a(Unknown Source:17)
	at io.flutter.embedding.engine.f.e.k(Unknown Source:18)
	at io.flutter.embedding.engine.f.e.l(Unknown Source:20)
	at io.flutter.embedding.engine.f.e.m(Unknown Source:0)
	at io.flutter.embedding.engine.f.c.run(Unknown Source:12)
	at android.os.Handler.handleCallback(Handler.java:938)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:226)
	at android.os.Looper.loop(Looper.java:313)
	at android.app.ActivityThread.main(ActivityThread.java:8669)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
). Error thrown null.
       at StandardMethodCodec.decodeEnvelope(message_codecs.dart:607)
       at MethodChannel._invokeMethod(platform_channel.dart:167)

Vibrate without user interaction

Hi! how to vibrate without user interaction? i'm making flutter app that read qr codes, and i want vibrate as feedback once qr is readed.

The vibrate function is usefull when i tap a button or i have interaction with the UI, but if i call from a stream or subscription the vibration is not triggered.

Regards

Deprecated Warning

I'm not sure If this should be reported. But I cannot figure out how this happened. All the codes seem to be right under Build.VERSION.SDK_INT. Is there anyway to omit the warning or change the code to suppress It? I used SuppressLint, but It seems to be no relation on this issue.

.pub-cache\hosted\pub.dartlang.org\vibration-1.0.2\android\src\main\java\com\benjaminabel\vibration\VibrationPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Edit:

.pub-cache\hosted\pub.dartlang.org\vibration-1.0.2\android\src\main\java\com\benjaminabel\vibration\VibrationPlugin.java:37: warning: [deprecation] vibrate(long) in Vibrator has been deprecated
                vibrator.vibrate(duration);
                        ^
.pub-cache\hosted\pub.dartlang.org\vibration-1.0.2\android\src\main\java\com\benjaminabel\vibration\VibrationPlugin.java:54: warning: [deprecation] vibrate(long[],int) in Vibrator has been deprecated
                vibrator.vibrate(patternLong, repeat);
                        ^
2 warnings

This is the details extracted, but this seems to be correct in Logic...um....

problem on installation

Downloading dependencies
-> Installing Flutter (1.0.0)
-> Installing vibrate (0.0.1)
- Running pre install hooks
[!] Unable to determine Swift version for the following pods:
- vibrate does not specify a Swift version and none of the targets (Runner) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.0/lib/cocoapods/installer/xcode/target_validator.rb:115:in verify_swift_pods_swift_version' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.0/lib/cocoapods/installer/xcode/target_validator.rb:37:in validate!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.0/lib/cocoapods/installer.rb:459:in validate_targets' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.0/lib/cocoapods/installer.rb:138:in install!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.0/lib/cocoapods/command/install.rb:48:in run' /Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.0/lib/cocoapods/command.rb:52:in run' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.0/bin/pod:55:in <top (required)>'
/usr/local/bin/pod:22:in load' /usr/local/bin/pod:22:in

'
Error running pod install
Exited (sigterm)

IOS didn't work

I have no problem on android but tried on 2 devices in ios it didn't work

He's working on a sample project on iOS. Doesn't work on my project I have repeatedly checked if everything is the same.

I would be glad if you could help about the problem.

thanks in advance

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.