• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

icapps / flutter-background-location-tracker / 6261542313

21 Sep 2023 12:20PM UTC coverage: 48.485% (+39.0%) from 9.459%
6261542313

push

github

web-flow
Merge pull request #63 from icapps/feature/methods-for-BackgroundLocationUpdateData

Added fromJson/toJson/toString/equals/copyWith methods in BackgroundLocationUpdateData

58 of 58 new or added lines in 1 file covered. (100.0%)

64 of 132 relevant lines covered (48.48%)

1.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.31
/lib/src/model/background_location_update_data.dart
1
import 'dart:convert';
2

3
/// BackgroundLocationUpdateData will contain all the data that is send when getting a background location update
4
///
5
/// latitude & longitude
6
class BackgroundLocationUpdateData {
7
  /// Latitude
8
  final double lat;
9

10
  /// Longitude
11
  final double lon;
12

13
  /// The radius of uncertainty for the location, measured in meters. Negative value if not available.
14
  final double horizontalAccuracy;
15

16
  /// Altitude
17
  final double alt;
18

19
  /// The validity of the altitude values, and their estimated uncertainty, measured in meters. Negative value if not available.
20
  final double verticalAccuracy;
21

22
  /// Direction in which the device is traveling, measured in degrees and relative to due north. Negative value if not available.
23
  final double course;
24

25
  /// The accuracy of the course value, measured in degrees. Negative value if not available.
26
  final double courseAccuracy;
27

28
  /// Instantaneous speed of the device, measured in meters per second. Negative value if not available.
29
  final double speed;
30

31
  /// The accuracy of the speed value, measured in meters per second. Negative value if not available.
32
  final double speedAccuracy;
33

34
  const BackgroundLocationUpdateData({
2✔
35
    required this.lat,
36
    required this.lon,
37
    required this.horizontalAccuracy,
38
    required this.alt,
39
    required this.verticalAccuracy,
40
    required this.course,
41
    required this.courseAccuracy,
42
    required this.speed,
43
    required this.speedAccuracy,
44
  });
45

46
  Map<String, dynamic> toMap() {
1✔
47
    return {
1✔
48
      'lat': lat,
1✔
49
      'lon': lon,
1✔
50
      'horizontalAccuracy': horizontalAccuracy,
1✔
51
      'alt': alt,
1✔
52
      'verticalAccuracy': verticalAccuracy,
1✔
53
      'course': course,
1✔
54
      'courseAccuracy': courseAccuracy,
1✔
55
      'speed': speed,
1✔
56
      'speedAccuracy': speedAccuracy,
1✔
57
    };
58
  }
59

60
  factory BackgroundLocationUpdateData.fromMap(Map<String, dynamic> map) {
1✔
61
    return BackgroundLocationUpdateData(
1✔
62
      lat: map['lat'].toDouble(),
2✔
63
      lon: map['lon'].toDouble(),
2✔
64
      horizontalAccuracy: map['horizontalAccuracy'].toDouble(),
2✔
65
      alt: map['alt'].toDouble(),
2✔
66
      verticalAccuracy: map['verticalAccuracy'].toDouble(),
2✔
67
      course: map['course'].toDouble(),
2✔
68
      courseAccuracy: map['courseAccuracy'].toDouble(),
2✔
69
      speed: map['speed'].toDouble(),
2✔
70
      speedAccuracy: map['speedAccuracy'].toDouble(),
2✔
71
    );
72
  }
73

74
  String toJson() => json.encode(toMap());
3✔
75

76
  factory BackgroundLocationUpdateData.fromJson(String source) => BackgroundLocationUpdateData.fromMap(json.decode(source));
3✔
77

78
  @override
1✔
79
  bool operator ==(Object other) {
80
    if (identical(this, other)) return true;
81

82
    return other is BackgroundLocationUpdateData &&
1✔
83
        other.lat == lat &&
3✔
84
        other.lon == lon &&
3✔
85
        other.horizontalAccuracy == horizontalAccuracy &&
3✔
86
        other.alt == alt &&
3✔
87
        other.verticalAccuracy == verticalAccuracy &&
3✔
88
        other.course == course &&
3✔
89
        other.courseAccuracy == courseAccuracy &&
3✔
90
        other.speed == speed &&
3✔
91
        other.speedAccuracy == speedAccuracy;
3✔
92
  }
93

94
  @override
1✔
95
  int get hashCode {
96
    return lat.hashCode ^
3✔
97
        lon.hashCode ^
3✔
98
        horizontalAccuracy.hashCode ^
3✔
99
        alt.hashCode ^
3✔
100
        verticalAccuracy.hashCode ^
3✔
101
        course.hashCode ^
3✔
102
        courseAccuracy.hashCode ^
3✔
103
        speed.hashCode ^
3✔
104
        speedAccuracy.hashCode;
2✔
105
  }
106

107
  @override
1✔
108
  String toString() {
109
    return 'BackgroundLocationUpdateData(lat: $lat, lon: $lon, horizontalAccuracy: $horizontalAccuracy, alt: $alt, verticalAccuracy: $verticalAccuracy, course: $course, courseAccuracy: $courseAccuracy, speed: $speed, speedAccuracy: $speedAccuracy)';
10✔
110
  }
111

112
  BackgroundLocationUpdateData copyWith({
1✔
113
    double? lat,
114
    double? lon,
115
    double? horizontalAccuracy,
116
    double? alt,
117
    double? verticalAccuracy,
118
    double? course,
119
    double? courseAccuracy,
120
    double? speed,
121
    double? speedAccuracy,
122
  }) {
123
    return BackgroundLocationUpdateData(
1✔
124
      lat: lat ?? this.lat,
×
125
      lon: lon ?? this.lon,
1✔
126
      horizontalAccuracy: horizontalAccuracy ?? this.horizontalAccuracy,
1✔
127
      alt: alt ?? this.alt,
1✔
128
      verticalAccuracy: verticalAccuracy ?? this.verticalAccuracy,
1✔
129
      course: course ?? this.course,
1✔
130
      courseAccuracy: courseAccuracy ?? this.courseAccuracy,
1✔
131
      speed: speed ?? this.speed,
1✔
132
      speedAccuracy: speedAccuracy ?? this.speedAccuracy,
1✔
133
    );
134
  }
135
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc