benjamindean / flutter_vibration

Handle vibration on iOS and Android in Flutter apps
217 stars 67 forks source link

Example wrong? #59

Closed m1pl closed 1 year ago

m1pl commented 3 years ago

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.

benjamindean commented 3 years ago

Also related to #55. I will fix the example as soon as I can.