Skip to content

Latest commit

 

History

History
42 lines (35 loc) · 913 Bytes

useAccelerometer.md

File metadata and controls

42 lines (35 loc) · 913 Bytes

useAccelerometer

Tracks the state of device accelerometer.

Installation

Depends on sensors_plus.

dependencies:
  flutter_use_sensors: ^0.0.2

Usage

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}"),
          ],
        ),
      ),
    );
  }
}

Reference

  • fetched: bool - whether device accelerometer state is fetched;
  • accelerometer: AccelerometerEvent - device accelerometer state changes.
    • x
    • y
    • z