Capture motion in Flutter apps

Forward shakes and accelerometer samples already observed by a Flutter mobile app into its Ansight session.

Motion capture is opt-in for Flutter apps on iOS and Android. ansight_flutter forwards observations to the native Ansight runtime; it does not start a sensor stream or request motion permissions. Use a motion source your app already owns.

Enable capture

Add withMotionCapture() to the options used during guarded app startup:

import 'package:ansight_flutter/ansight.dart';

final options = createOptionsBuilder()
    .withAnsightDefaults()
    .withMotionCapture()
    .build();

await Ansight.instance.initializeAndActivate(options);

Initialize once before runApp(...), as described in Flutter Setup.

Forward observations

Call the runtime from your existing shake or sensor callback:

await Ansight.instance.recordShake();
await Ansight.instance.recordAccelerometer(x, y, z); // m/s²

Android accelerometer values are already in metres per second squared. Convert Apple accelerometer values from g by multiplying each axis by 9.80665 before forwarding. Ansight does not add a Flutter sensor subscription.

Both event types are enabled by default within withMotionCapture(). Pass AnsightMotionCaptureOptions to disable either type or set minimumSampleIntervalMilliseconds; the interval defaults to 20 ms and is clamped to 10–1000 ms.

The host stores app-observed motion in motion/events.json and the session’s motion timeline. For host-injected device motion and the shared evidence contract, see Motion Capture.