sensors_plus 0.5.0

Flutter Android iOS web

Flutter plugin for accessing accelerometer and gyroscope sensors.

sensors #

Flutter Community: sensors_plus

pub package

A Flutter plugin to access the accelerometer and gyroscope sensors.

Usage #

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

This will expose three classes of sensor events, through three 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.

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

Example #

import 'package:sensors_plus/sensors_plus.dart';

accelerometerEvents.listen((AccelerometerEvent event) {
  print(event);
});
// [AccelerometerEvent (x: 0.0, y: 9.8, z: 0.0)]

userAccelerometerEvents.listen((UserAccelerometerEvent event) {
  print(event);
});
// [UserAccelerometerEvent (x: 0.0, y: 0.0, z: 0.0)]

gyroscopeEvents.listen((GyroscopeEvent event) {
  print(event);
});
// [GyroscopeEvent (x: 0.0, y: 0.0, z: 0.0)]

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

2
likes
110
pub points
0%
popularity

Publisher

fluttercommunity.dev

Flutter plugin for accessing accelerometer and gyroscope sensors.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD (LICENSE)

Dependencies

flutter, sensors_plus_platform_interface, sensors_plus_web

More

Packages that depend on sensors_plus