SensorEvent.fromMap constructor

SensorEvent.fromMap(
  1. Map map
)

Implementation

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

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