location.dart 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import 'package:sport/services/Converter.dart';
  2. class Location {
  3. double latitude;
  4. double longitude;
  5. final double? altitude;
  6. final double? speed;
  7. /// 地址
  8. final String? address;
  9. /// 国家
  10. final String? country;
  11. /// 省
  12. final String? province;
  13. /// 市
  14. final String? city;
  15. final String? citycode;
  16. final String? adcode;
  17. /// 区
  18. final String? district;
  19. /// 街道
  20. final String? street;
  21. /// 精准度 [在web端直接返回0]
  22. final double? accuracy;
  23. final double? bearing;
  24. final int? locationType;
  25. int? state;
  26. int? time;
  27. int? step;
  28. Location({
  29. this.latitude =0,
  30. this.longitude=0,
  31. this.accuracy,
  32. this.altitude,
  33. this.speed,
  34. this.address,
  35. this.city,
  36. this.country,
  37. this.district,
  38. this.street,
  39. this.province,
  40. this.bearing,
  41. this.citycode,this.adcode,this.state,this.time,this.step,
  42. this.locationType
  43. });
  44. factory Location.fromJson(Map<dynamic, dynamic> json) => _$LocationFromJson(json);
  45. Map<String, dynamic> toJson() => _$LocationToJson(this);
  46. Location copyWith({
  47. double? latitude,
  48. double? longitude,
  49. double? altitude,
  50. double? speed,
  51. String? address,
  52. String? country,
  53. String? province,
  54. String? city,
  55. String? citycode,
  56. String? adcode,
  57. String? district,
  58. String? street,
  59. double? accuracy,
  60. int? state,
  61. int? time,
  62. int? step,
  63. double? bearing,
  64. int? locationType,
  65. }) {
  66. return new Location(
  67. latitude: latitude ?? this.latitude,
  68. longitude: longitude ?? this.longitude,
  69. altitude: altitude ?? this.altitude,
  70. speed: speed ?? this.speed,
  71. address: address ?? this.address,
  72. country: country ?? this.country,
  73. province: province ?? this.province,
  74. city: city ?? this.city,
  75. citycode: citycode ?? this.citycode,
  76. adcode: adcode ?? this.adcode,
  77. district: district ?? this.district,
  78. street: street ?? this.street,
  79. accuracy: accuracy ?? this.accuracy,
  80. state: state ?? this.state,
  81. time: time ?? this.time,
  82. step: step ?? this.step,
  83. bearing: bearing ?? this.bearing,
  84. locationType: locationType ?? this.locationType,
  85. );
  86. }
  87. }
  88. Location _$LocationFromJson(Map<dynamic, dynamic> json) {
  89. return Location(
  90. latitude: Converter.toDouble(json['latitude']),
  91. longitude: Converter.toDouble(json['longitude']),
  92. accuracy: Converter.toDouble(json['accuracy']),
  93. altitude: Converter.toDouble(json['altitude']),
  94. address: json['address'] as String,
  95. city: json['city'] as String,
  96. country: json['country'] as String,
  97. district: json['district'] as String,
  98. street: json['street'] as String,
  99. province: json['province'] as String,
  100. citycode: json['cityCode'] as String,
  101. adcode: json['adCode'] as String,
  102. speed: Converter.toDouble(json['speed']),
  103. step: Converter.toInt(json['step']),
  104. state: Converter.toInt(json['state']),
  105. time: Converter.toInt(json['time']),
  106. bearing: Converter.toDouble(json['bearing']),
  107. locationType: Converter.toInt(json['locationType']),
  108. );
  109. }
  110. Map<String, dynamic> _$LocationToJson(Location instance) => <String, dynamic>{
  111. 'latitude': instance.latitude,
  112. 'longitude': instance.longitude,
  113. 'accuracy': instance.accuracy,
  114. 'bearing': instance.bearing,
  115. 'locationType': instance.locationType,
  116. 'speed': instance.speed,
  117. };