flutter_vibrate icon indicating copy to clipboard operation
flutter_vibrate copied to clipboard

Optional param for vibrate() and added cancel()

Open Ivolutio opened this issue 6 years ago • 5 comments

For Android, I also changed the if statements in onMethodCall to a switch case. I do not know how to do stuff for iOS, so I only implemented a TODO line for cancel().

Ivolutio avatar Mar 04 '18 15:03 Ivolutio

😮 I completely skipped over this part in the readme:

// Vibrate
// Vibration duration is a constant 500ms because 
// it cannot be set to a specific duration on iOS.
Vibrate.vibrate()

But, I didn't see you using anything with call arguments in iOS to specify duration, like it's done in Android.. So I do think that would be fine, right? 😅

I also forgot to add it to the example in the readme, but I'll do that if you have accepted this pull 😄.

Ivolutio avatar Mar 04 '18 15:03 Ivolutio

I removed the duration parameter on the dart vibrate method because I haven't found a way to vibrate for a specific duration on iOS, and I wanted the result to be the same on both platforms. It can be frustrating to have a different result on both platforms. Same for the cancel() method, I'm not sure this is feasible on iOS, as the duration is always the same. However, we could add a method to cancel the vibration with pattern on both platforms

clovisnicolas avatar Mar 05 '18 08:03 clovisnicolas

I understand, but you wouldn't want to exclude the features from Android either, right? 😞

Ivolutio avatar Mar 05 '18 08:03 Ivolutio

Well I know this is debatable, but I think plugins should only expose the common subset of platform features. I find it frustrating to have shared code which behaves differently on both platforms, but once again, this is only my opinion ;)

clovisnicolas avatar Mar 05 '18 09:03 clovisnicolas

Maybe it could be an idea to have this then? I am currently using a long vibration to keep vibrating until I release a button. (Android)

if (Platform.isIOS) {
  Vibrate.vibrate(); //normal 500ms
}
else if (Platform.isAndroid) {
  Vibrate.vibrateAndroid(new Duration(...)); //custom duration
}

(This is the code the user will enter)

Ivolutio avatar Mar 05 '18 09:03 Ivolutio