headless_level

A headless level for iOS. No widgets — just a typed stream of the device gravity vector.

Usage

final source = LevelSource();
if (await source.isAvailable()) {
  source.watch().listen((s) {
    print('${s.gx} ${s.gy} ${s.gz} — tilt ${s.tiltDeg}°');
  });
}

Coordinates

The gravity vector is a unit vector in the device frame, straight from CMDeviceMotion.gravity:

Pose Vector
Flat on its back, screen up (0, 0, -1)
Upright in portrait (0, -1, 0)
Flat on its face, screen down (0, 0, 1)

tiltDeg is the angle between the back of the device and the horizontal plane, 0 to 180. It is derived from gz alone; the two horizontal components are what a bubble needs, which is why the raw vector is what this package returns.

Guarantees

  • Never throws. A dead platform channel gives isAvailable() == false.
  • No widgets.
  • No permissions — CoreMotion asks for none.
  • iOS only. There is nothing to run on other platforms.

License

MIT.

Libraries

headless_level