benjamindean / flutter_vibration

Handle vibration on iOS and Android in Flutter apps
219 stars 68 forks source link

How to set the vibration for one hr #47

Closed vipuluthaiah closed 3 years ago

vipuluthaiah commented 3 years ago

How can i set the interval of vibration for more than hrs, eg: RaisedButton( child: Text('Vibrate for 1000ms'), onPressed: () { Vibration.vibrate(duration: 100000, repeat: 90000000); }, ),

how can i set it for hrs? or vibrate untill we tap Vibration.cancel();

benjamindean commented 3 years ago

What exactly is the problem? Doesn't it vibrate this way? It's quite a rare case, so vibrating indefinitely is not "officially" supported, but it's possible.

vipuluthaiah commented 3 years ago

vibration works fine but for me when the button is clicked i want the vibration to last for one hour or more how to implement this?

vipuluthaiah commented 3 years ago

i am working on a alarm app: when the alarm is on it shouble keep on vibrating for one hr or more when the user click on off button the vibration should off . so how can i do that?

benjamindean commented 3 years ago

Well, you just set the duration to 1000 60 60. Or use the Duration class for that.

vipuluthaiah commented 3 years ago

Thanks a lot!!great package by the way

vipuluthaiah commented 3 years ago

i tried to final dur = Duration( days: 5, hours: 23, minutes: 59, seconds: 59, milliseconds: 999, microseconds: 999, ); RaisedButton( child: Text('Vibrate for 1000ms'), onPressed: () { Vibration.vibrate(duration: 1000 60 60, ); }, ), but its not working! and i did try Duration class for one hr its not working child: Text('Vibrate for 1000ms'), onPressed: () { Vibration.vibrate(duration: 100 60 60, ); // Vibration.vibrate(duration: Duration.secondsPerMinute); // Vibration.vibrate(duration:d1.inMinutes 10060*600); Vibration.vibrate(duration:dur.inMinutes );

                },
              ),
benjamindean commented 3 years ago

Judging by your code you are passing minutes to the vibrate method. What happens when you run Vibration.vibrate(duration: 1000 * 60 * 60);?

vipuluthaiah commented 3 years ago

it doesnt workk

vipuluthaiah commented 3 years ago

it will not vibrate at all

vipuluthaiah commented 3 years ago

RaisedButton( child: Text('Vibrate for default 500ms'), onPressed: () { Vibration.vibrate(duration: 1000 60 60); }, ),

Vibrated for :10s0