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