deven98 / shake

A flutter package for detecting phone shakes.
BSD 2-Clause "Simplified" License
95 stars 63 forks source link

How the library works? #9

Closed sm2017 closed 2 years ago

sm2017 commented 3 years ago

We have a int mShakeCount = 0; at shake.dart#L26 that reset in shake.dart#L70 and mShakeCount++ at shake.dart#L74 there is no other usage of this variable , the variable is redundant and if your remove it nothing changed

onPhoneShake calls only gForce > shakeThresholdGravity in each event so it is not technically a shake?! just a rapid movement!

mixable commented 2 years ago

I also saw this behavior. onPhoneShake is already triggered on a fast movement. I think @sm2017 is correct, the variable mShakeCount is never used to see how many movements have been performed. For correct function, some kind of value check against mShakeCount is necessary.

deven98 commented 2 years ago

This is a valid point, just pushed v2.1.0 with a minimum number of shakes required for triggering the callback.

Thanks so much for reporting this issue.