123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- import 'dart:convert';
- import 'dart:io';
- import 'dart:convert' as convert;
- import 'package:sport/pages/run/location.dart';
- import 'package:sport/services/Converter.dart';
- class JogDetail {
- int? id;
- int? userId;
- String? type;
- int? recordId;
- int? consume;
- int? duration;
- int? step;
- int? distance;
- int? crouch;
- int? jump;
- double? stepRate;
- String? createdAt;
- int? jumpRate;
- int? crouchRate;
- String? begin;
- String? end;
- String? track;
- List<int>? kmDurationInfo;
- String? stepInfo;
- String? altitudeInfo;
- int? kmDurationBest;
- int? activeDay;
- String? trackThumb;
- double? met;
- List<Location>? points;
- JogDetail(
- {this.id,
- this.userId,
- this.type,
- this.recordId,
- this.consume,
- this.duration,
- this.step,
- this.distance,
- this.crouch,
- this.jump,
- this.stepRate,
- this.createdAt,
- this.jumpRate,
- this.crouchRate,
- this.begin,
- this.end,
- this.track,
- this.kmDurationInfo,
- this.stepInfo,
- this.altitudeInfo,
- this.kmDurationBest,
- this.activeDay});
- JogDetail.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- userId = json['user_id'];
- type = json['type'];
- recordId = json['record_id'];
- consume = json['consume'];
- duration = json['duration'];
- step = json['step'];
- distance = json['distance'];
- crouch = json['crouch'];
- jump = json['jump'];
- stepRate = Converter.toDouble(json['step_rate']);
- createdAt = json['created_at'];
- jumpRate = json['jump_rate'];
- crouchRate = json['crouch_rate'];
- begin = json['begin'];
- end = json['end'];
- track = json['track'];
- if (track?.isNotEmpty == true) {
- points = [];
- String _track;
- if (track!.startsWith("[{")) {
- _track = track!;
- } else if (track!.startsWith("[")) {
- List<int> array = convert.json.decode(track!).cast<int>();
- var compressed = gzip.decode(array);
- var original = utf8.decode(compressed);
- _track = original;
- }else {
- var trackInfo = base64.decode(track!);
- var compressed = gzip.decode(trackInfo);
- var original = utf8.decode(compressed);
- _track = original;
- }
- var list = convert.json.decode(_track);
- list.forEach((v) {
- points!.add(Location.fromJson(v));
- });
- }
- kmDurationInfo = json['km_duration_info'] != null ? json['km_duration_info'].cast<int>() : <int>[];
- stepInfo = json['step_info'];
- altitudeInfo = json['altitude_info'];
- kmDurationBest = json['km_duration_best'];
- activeDay = json['active_day'];
- trackThumb = json['track_thumb'];
- met = Converter.toDouble(json['met']);
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['user_id'] = this.userId;
- data['type'] = this.type;
- data['record_id'] = this.recordId;
- data['consume'] = this.consume;
- data['duration'] = this.duration;
- data['step'] = this.step;
- data['distance'] = this.distance;
- data['crouch'] = this.crouch;
- data['jump'] = this.jump;
- data['step_rate'] = this.stepRate;
- data['created_at'] = this.createdAt;
- data['jump_rate'] = this.jumpRate;
- data['crouch_rate'] = this.crouchRate;
- data['begin'] = this.begin;
- data['end'] = this.end;
- data['track'] = this.track;
- data['km_duration_info'] = this.kmDurationInfo;
- data['step_info'] = this.stepInfo;
- data['altitude_info'] = this.altitudeInfo;
- data['km_duration_best'] = this.kmDurationBest;
- data['met'] = this.met;
- return data;
- }
- }
|