SensorEvent.fromMap constructor

SensorEvent.fromMap(
  1. Map map
)

Implementation

factory SensorEvent.fromMap(Map<dynamic, dynamic> map) {
  DateTime time = DateTime.fromMillisecondsSinceEpoch(map['timestamp']);
  int index = map['packetIndex'];
  List<int> accl = [map['accel.x'], map['accel.y'], map['accel.z']];
  List<int> gyro = [map['gyro.x'], map['gyro.y'], map['gyro.z']];

  return SensorEvent(timestamp: time, packetIndex: index, accel: accl, gyro: gyro);
}