fromMap static method
Converts the supplied Map to an instance of the Location class.
Implementation
static Location fromMap(dynamic message) {
if (message == null) {
throw ArgumentError('The parameter \'message\' should not be null.');
}
final Map<dynamic, dynamic> locationMap = message;
final timestamp = DateTime.fromMillisecondsSinceEpoch(
locationMap['timestamp'].toInt(),
isUtc: true);
if (locationMap['latitude'] == null || locationMap['longitude'] == null) {
throw ArgumentError(
'The parameters latitude and longitude should not be null.');
}
return Location._(
latitude: locationMap['latitude'],
longitude: locationMap['longitude'],
timestamp: timestamp,
);
}