import 'package:sport/services/Converter.dart'; class SportTarget { int id; String name; String intension; int duration; int consume; String fitPeople; int sort; int userId; String type; int monthFinish; int durationMinute; SportTarget( {this.id, this.name, this.intension, this.duration, this.consume, this.fitPeople, this.sort, this.userId}); SportTarget.fromJson(Map json) { id = json['id']; name = json['name']; intension = json['intension']; duration = json['duration']; consume = json['consume']; fitPeople = json['fit_people']; sort = json['sort']; userId = Converter.toInt(json['user_id']); type = json['type']; monthFinish = json['month_finish']; durationMinute = json['duration_minute']; } Map toJson() { final Map data = new Map(); data['id'] = this.id; data['name'] = this.name; data['intension'] = this.intension; data['duration'] = this.duration; data['consume'] = this.consume; data['fit_people'] = this.fitPeople; data['sort'] = this.sort; data['user_id'] = this.userId; data['type'] = this.type; data['month_finish'] = this.monthFinish; data['duration_minute'] = this.durationMinute; return data; } int get valueTarget => type == "consume" ? consume : durationMinute; String get label => type == "consume" ? "卡" : "分钟"; }