Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 847 Bytes

useGyroscope.md

File metadata and controls

41 lines (34 loc) · 847 Bytes

useGyroscope

Tracks the state of device gyroscope.

Installation

Depends on sensors_plus.

dependencies:
  flutter_use_sensors: ^0.0.2

Usage

class Sample extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final gyroscopeState = useGyroscope();
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Text("gyroscope: ${gyroscopeState.gyroscope}"),
          ],
        ),
      ),
    );
  }
}

Reference

  • fetched: bool - whether device gyroscope state is fetched;
  • gyroscope: GyroscopeEvent - device gyroscope state changes.
    • x
    • y
    • z