123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- import 'package:sport/services/Converter.dart';
- class SportStep {
- List<Record>? records;
- Sum? sum;
- List<int>? steps;
- SportStep({this.records, this.sum});
- SportStep.fromJson(Map<String, dynamic> json) {
- if (json['records'] != null) {
- records =[];
- json['records'].forEach((v) {
- records!.add(new Record.fromJson(v));
- });
- }
- steps =json['steps'] != null ? json['steps'].cast<int>() : <int>[];
- sum = json['sum'] != null ? new Sum.fromJson(json['sum']) : null;
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- if (this.records != null) {
- data['records'] = this.records!.map((v) => v.toJson()).toList();
- }
- if (this.sum != null) {
- data['sum'] = this.sum!.toJson();
- }
- return data;
- }
- }
- class Record {
- int? id;
- int? userId;
- int? step;
- int? distance;
- int? stepGame;
- int? stepDaily;
- int? stepJog;
- String? createdAt;
- int? year;
- int? month;
- Record(
- {this.id,
- this.userId,
- this.step,
- this.distance,
- this.stepGame,
- this.stepDaily,
- this.createdAt});
- Record.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- userId = json['user_id'];
- step = json['step'];
- distance = json['distance'];
- stepGame = json['step_game'];
- stepDaily = json['step_daily'];
- stepJog = json['step_jog'];
- createdAt = json['created_at'];
- year = json['year'];
- month = json['month'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['user_id'] = this.userId;
- data['step'] = this.step;
- data['distance'] = this.distance;
- data['step_game'] = this.stepGame;
- data['step_daily'] = this.stepDaily;
- data['created_at'] = this.createdAt;
- data['step_jog'] = this.stepJog;
- return data;
- }
- }
- class Sum {
- double stepDayAvg = 0;
- int distance = 0;
- int step = 0;
- int stepDaily = 0;
- int stepGame = 0;
- int stepJog = 0;
- double stepRate= 0;
- double stepRateMax= 0;
- Sum(
- {this.stepDayAvg= 0,
- this.distance= 0,
- this.step = 0,
- this.stepDaily = 0,
- this.stepGame = 0,
- this.stepRate = 0,
- this.stepRateMax = 0});
- Sum.fromJson(Map<String, dynamic> json) {
- stepDayAvg = Converter.toDouble(json['step_day_avg']);
- distance = json['distance'];
- step = json['step'];
- stepDaily = json['step_daily'];
- stepGame = json['step_game'];
- stepJog = json['step_jog'];
- stepRate = Converter.toDouble(json['step_rate']);
- stepRateMax = Converter.toDouble(json['step_rate_max']);
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['step_day_avg'] = this.stepDayAvg;
- data['distance'] = this.distance;
- data['step'] = this.step;
- data['step_daily'] = this.stepDaily;
- data['step_game'] = this.stepGame;
- data['step_rate'] = this.stepRate;
- data['step_rate_max'] = this.stepRateMax;
- return data;
- }
- int get total{
- return stepDaily + stepGame + stepJog;
- }
- }
|