dvAndroidSensorSample function

Map<String, double>? dvAndroidSensorSample(
  1. List<double> values
)

One sample from a motion sensor, or null when the event does not carry three axes.

Null rather than a padded map, because a padded map is the most plausible wrong answer this binding can give: a phone lying still on a table reads near zero on two axes, so {x: 0, y: 0, z: 0} from a truncated event is indistinguishable from a real reading and nothing downstream can catch it.

Values past the third are dropped. An uncalibrated gyroscope reports six — three rates, then three drift estimates — and drift is not an axis.

Implementation

Map<String, double>? dvAndroidSensorSample(List<double> values) {
  if (values.length < 3) return null;
  return <String, double>{'x': values[0], 'y': values[1], 'z': values[2]};
}