import 'package:sport/services/Converter.dart'; class SportStep { List? records; Sum? sum; List? steps; SportStep({this.records, this.sum}); SportStep.fromJson(Map json) { if (json['records'] != null) { records =[]; json['records'].forEach((v) { records!.add(new Record.fromJson(v)); }); } steps =json['steps'] != null ? json['steps'].cast() : []; sum = json['sum'] != null ? new Sum.fromJson(json['sum']) : null; } Map toJson() { final Map data = new Map(); 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 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 toJson() { final Map data = new Map(); 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 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 toJson() { final Map data = new Map(); 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; } }