onDeviceMotion method
Implementation
void onDeviceMotion(JSObject e) {
final event = e.dartify() as dynamic;
final now = DateTime.now();
if (now.difference(lastDeviceMotionEvent) < _updateInterval.duration) {
/// Drop events more frequent than [_updateInterval]
return;
}
lastDeviceMotionEvent = now;
var interval = event.interval ?? 1;
_gyroscopeStreamController!.add(
MotionEvent(
type: MotionType.gyroscope,
x: (event.rotationRate?.alpha as double? ?? 0) * interval,
y: (event.rotationRate?.beta as double? ?? 0) * interval,
z: (event.rotationRate?.gamma as double? ?? 0) * interval,
),
);
}