sensors_plus 1.2.1

Get this package on


Flutter Community: sensors_plus

pub package



A Flutter plugin to access the accelerometer, gyroscope, and magnetometer sensors.

Platform Support



To use this plugin, add sensors_plus as a dependency in your pubspec.yaml file.

This will expose four classes of sensor events through four different streams.

  • AccelerometerEvents describe the velocity of the device, including the effects of gravity. Put simply, you can use accelerometer readings to tell if the device is moving in a particular direction.
  • UserAccelerometerEvents also describe the velocity of the device, but don’t include gravity. They can also be thought of as just the user’s affect on the device.
  • GyroscopeEvents describe the rotation of the device.
  • MagnetometerEvents describe the ambient magnetic field surrounding the device. A compass is an example usage of this data.

Each of these is exposed through a BroadcastStream: accelerometerEvents,userAccelerometerEvents, gyroscopeEvents, and magnetometerEvents, respectively.


import 'package:sensors_plus/sensors_plus.dart';
accelerometerEvents.listen((AccelerometerEvent event) {
// [AccelerometerEvent (x: 0.0, y: 9.8, z: 0.0)]
userAccelerometerEvents.listen((UserAccelerometerEvent event) {
// [UserAccelerometerEvent (x: 0.0, y: 0.0, z: 0.0)]
gyroscopeEvents.listen((GyroscopeEvent event) {
// [GyroscopeEvent (x: 0.0, y: 0.0, z: 0.0)]
magnetometerEvents.listen((MagnetometerEvent event) {
// [MagnetometerEvent (x: -23.6, y: 6.2, z: -34.9)]

Also see the example subdirectory for an example application that uses the sensor data.

Check out our website to learn more: Plus Plugins documentation

Important: As of January 2021, the Flutter team is no longer accepting non-critical PRs for the original set of plugins in flutter/plugins, and instead they should be submitted in this project. You can read more about this announcement here as well as in the Flutter 2 announcement blog post.