benjamindean / flutter_vibration

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

Vibration not working in first few calls #68

Closed dovahkiin98 closed 1 year ago

dovahkiin98 commented 2 years ago

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

benjamindean commented 2 years ago

If it's not isolated to one package, I would recommend using it inside the async loop. So, you'll have to await for the vibrate call. I'm not sure, but I think that's how Flutter handles its async calls.

dovahkiin98 commented 2 years ago

@benjamindean Not sure how awaiting the call helps? I'm not waiting for the response. Also, it works fine on Android, so it's not the code, it's the platform

benjamindean commented 2 years ago

Yeah, iOS is behaving quite weirdly, even according to the reported issues here. I'm unable to test it on a real iOS device, so I'll take a look at the code I've more, but not promising that it can be fixed. Meanwhile, try to awaiting for the call.