flutter_vibrate
flutter_vibrate copied to clipboard
Optional param for vibrate() and added cancel()
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().
😮 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 😄.
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
I understand, but you wouldn't want to exclude the features from Android either, right? 😞
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 ;)
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)