123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- import 'package:sport/services/Converter.dart';
- class Location {
- double latitude;
- double longitude;
- final double? altitude;
- final double? speed;
- /// 地址
- final String? address;
- /// 国家
- final String? country;
- /// 省
- final String? province;
- /// 市
- final String? city;
- final String? citycode;
- final String? adcode;
- /// 区
- final String? district;
- /// 街道
- final String? street;
- /// 精准度 [在web端直接返回0]
- final double? accuracy;
- final double? bearing;
- final int? locationType;
- int? state;
- int? time;
- int? step;
- Location({
- this.latitude =0,
- this.longitude=0,
- this.accuracy,
- this.altitude,
- this.speed,
- this.address,
- this.city,
- this.country,
- this.district,
- this.street,
- this.province,
- this.bearing,
- this.citycode,this.adcode,this.state,this.time,this.step,
- this.locationType
- });
- factory Location.fromJson(Map<dynamic, dynamic> json) => _$LocationFromJson(json);
- Map<String, dynamic> toJson() => _$LocationToJson(this);
- Location copyWith({
- double? latitude,
- double? longitude,
- double? altitude,
- double? speed,
- String? address,
- String? country,
- String? province,
- String? city,
- String? citycode,
- String? adcode,
- String? district,
- String? street,
- double? accuracy,
- int? state,
- int? time,
- int? step,
- double? bearing,
- int? locationType,
- }) {
- return new Location(
- latitude: latitude ?? this.latitude,
- longitude: longitude ?? this.longitude,
- altitude: altitude ?? this.altitude,
- speed: speed ?? this.speed,
- address: address ?? this.address,
- country: country ?? this.country,
- province: province ?? this.province,
- city: city ?? this.city,
- citycode: citycode ?? this.citycode,
- adcode: adcode ?? this.adcode,
- district: district ?? this.district,
- street: street ?? this.street,
- accuracy: accuracy ?? this.accuracy,
- state: state ?? this.state,
- time: time ?? this.time,
- step: step ?? this.step,
- bearing: bearing ?? this.bearing,
- locationType: locationType ?? this.locationType,
- );
- }
- }
- Location _$LocationFromJson(Map<dynamic, dynamic> json) {
- return Location(
- latitude: Converter.toDouble(json['latitude']),
- longitude: Converter.toDouble(json['longitude']),
- accuracy: Converter.toDouble(json['accuracy']),
- altitude: Converter.toDouble(json['altitude']),
- address: json['address'] as String,
- city: json['city'] as String,
- country: json['country'] as String,
- district: json['district'] as String,
- street: json['street'] as String,
- province: json['province'] as String,
- citycode: json['cityCode'] as String,
- adcode: json['adCode'] as String,
- speed: Converter.toDouble(json['speed']),
- step: Converter.toInt(json['step']),
- state: Converter.toInt(json['state']),
- time: Converter.toInt(json['time']),
- bearing: Converter.toDouble(json['bearing']),
- locationType: Converter.toInt(json['locationType']),
- );
- }
- Map<String, dynamic> _$LocationToJson(Location instance) => <String, dynamic>{
- 'latitude': instance.latitude,
- 'longitude': instance.longitude,
- 'accuracy': instance.accuracy,
- 'bearing': instance.bearing,
- 'locationType': instance.locationType,
- 'speed': instance.speed,
- };
|