Tracks the state of device accelerometer.
Depends on sensors_plus.
dependencies:
flutter_use_sensors: ^0.0.2
class Sample extends HookWidget {
@override
Widget build(BuildContext context) {
final accelerometerState = useAccelerometer();
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"accelerometerState: ${accelerometerState.accelerometer}"),
],
),
),
);
}
}
fetched
: bool
- whether device accelerometer state is fetched;accelerometer
: AccelerometerEvent
- device accelerometer state changes.x
y
z