stopListening method
void
stopListening()
Starts listening to accelerometer events Stops listening to accelerometer events
Implementation
// void startListening() {
// streamSubscription = accelerometerEvents.listen((AccelerometerEvent event) {
// final double x = event.x;
// final double y = event.y;
// final double z = event.z;
//
// final double gX = x / 9.80665;
// final double gY = y / 9.80665;
// final double gZ = z / 9.80665;
//
// // gForce will be close to 1 when there is no movement.
// final double gForce = sqrt(gX * gX + gY * gY + gZ * gZ);
//
// if (gForce > shakeThresholdGravity) {
// final now = DateTime.now().millisecondsSinceEpoch;
// // ignore shake events too close to each other (500ms)
// if (mShakeTimestamp + shakeSlopTimeMS > now) {
// return;
// }
//
// // reset the shake count after 3 seconds of no shakes
// if (mShakeTimestamp + shakeCountResetTime < now) {
// mShakeCount = 0;
// }
//
// mShakeTimestamp = now;
// mShakeCount++;
//
// onPhoneShake!();
// }
// });
// }
/// Stops listening to accelerometer events
void stopListening() {
if (streamSubscription != null) {
streamSubscription!.cancel();
}
}