-
Notifications
You must be signed in to change notification settings - Fork 370
/
Copy pathlocation_dto.dart
66 lines (60 loc) · 1.75 KB
/
location_dto.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import 'dart:io' show Platform;
import 'keys.dart';
class LocationDto {
final double latitude;
final double longitude;
final double accuracy;
final double altitude;
final double speed;
final double speedAccuracy;
final double heading;
final double time;
final bool isMocked;
final String provider;
LocationDto._(
this.latitude,
this.longitude,
this.accuracy,
this.altitude,
this.speed,
this.speedAccuracy,
this.heading,
this.time,
this.isMocked,
this.provider,
);
factory LocationDto.fromJson(Map<dynamic, dynamic> json) {
bool isLocationMocked =
Platform.isAndroid ? json[Keys.ARG_IS_MOCKED] : false;
return LocationDto._(
json[Keys.ARG_LATITUDE],
json[Keys.ARG_LONGITUDE],
json[Keys.ARG_ACCURACY],
json[Keys.ARG_ALTITUDE],
json[Keys.ARG_SPEED],
json[Keys.ARG_SPEED_ACCURACY],
json[Keys.ARG_HEADING],
json[Keys.ARG_TIME],
isLocationMocked,
json.containsKey(Keys.ARG_PROVIDER) ? json[Keys.ARG_PROVIDER] : "",
);
}
Map<String, dynamic> toJson() {
return {
Keys.ARG_LATITUDE: this.latitude,
Keys.ARG_LONGITUDE: this.longitude,
Keys.ARG_ACCURACY: this.accuracy,
Keys.ARG_ALTITUDE: this.altitude,
Keys.ARG_SPEED: this.speed,
Keys.ARG_SPEED_ACCURACY: this.speedAccuracy,
Keys.ARG_HEADING: this.heading,
Keys.ARG_TIME: this.time,
Keys.ARG_IS_MOCKED: this.isMocked,
Keys.ARG_PROVIDER: this.provider,
};
}
@override
String toString() {
return 'LocationDto{latitude: $latitude, longitude: $longitude, accuracy: $accuracy, altitude: $altitude, speed: $speed, speedAccuracy: $speedAccuracy, heading: $heading, time: $time, isMocked: $isMocked, provider: $provider}';
}
}