benjamindean / flutter_vibration

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

Null check operator called on null Value #66

Closed umersaddiq closed 1 year ago

umersaddiq commented 2 years ago

On Vibration.vibrate() it throws a message null check operator called on null value

Flutter Version 2.8.1 Dart Version 2.15.1

benjamindean commented 2 years ago

Can you, please, provide an example? And remember that the plugin only supports async calls.

dVeki commented 1 year ago

I had the same issue on my web project using flutter null safety. This is the code used for solution: try { bool? hasVibration = await Vibration.hasVibrator(); if (hasVibration != null && hasVibration) { bool? hasCustomVibration = await Vibration.hasCustomVibrationsSupport(); if (hasCustomVibration != null && hasCustomVibration) { await Vibration.vibrate(duration: c.duration!); } else { await Vibration.vibrate(); } } }...

benjamindean commented 1 year ago

Should be solved in the latest version.