Optional param for vibrate() and added cancel()#1
Optional param for vibrate() and added cancel()#1Ivolutio wants to merge 2 commits intoclovisnicolas:masterfrom
Conversation
I am not sure if this works for iOS, since I do not own one.
Don't know how to do it for iOS.
|
😮 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. |
|
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) |
For Android, I also changed the if statements in
onMethodCallto a switch case.I do not know how to do stuff for iOS, so I only implemented a TODO line for cancel().