LocationUpdateEvent.fromMap constructor

LocationUpdateEvent.fromMap(
  1. Map<Object?, Object?> map
)

Implementation

factory LocationUpdateEvent.fromMap(Map<Object?, Object?> map) {
  double readDouble(String k1, [String? k2]) =>
      ((map[k1] ?? (k2 != null ? map[k2] : null)) as num?)?.toDouble() ?? 0.0;

  return LocationUpdateEvent(
    latitude:  readDouble('latitude',  'lat'),
    longitude: readDouble('longitude', 'lng'),
    altitude:  readDouble('altitude'),
    accuracy:  readDouble('accuracy'),
    speed:     readDouble('speed'),
    heading:   readDouble('heading',  'bearing'),
    timestamp: (map['timestamp'] as num?)?.toInt() ??
               DateTime.now().millisecondsSinceEpoch,
  );
}