class SportTargetDay { int id; int userId; int consume; int duration; int consumeTarget; int durationTarget; bool finish; String type; String createdAt; int durationMinute; int durationTargetMinute; SportTargetDay( {this.id, this.userId, this.consume, this.duration, this.consumeTarget, this.durationTarget, this.finish, this.type, this.createdAt, this.durationMinute, this.durationTargetMinute}); SportTargetDay.fromJson(Map json) { id = json['id']; userId = json['user_id']; consume = json['consume']; duration = json['duration']; consumeTarget = json['consume_target']; durationTarget = json['duration_target']; finish = json['finish']; type = json['type']; createdAt = json['created_at']; durationMinute = json['duration_minute']; durationTargetMinute = json['duration_target_minute']; } Map toJson() { final Map data = new Map(); data['id'] = this.id; data['user_id'] = this.userId; data['consume'] = this.consume; data['duration'] = this.duration; data['consume_target'] = this.consumeTarget; data['duration_target'] = this.durationTarget; data['finish'] = this.finish; data['type'] = this.type; data['created_at'] = this.createdAt; data['duration_minute'] = this.durationMinute; data['duration_target_minute'] = this.durationTargetMinute; return data; } int get value => type == "consume" ? consume : durationMinute; int get valueTarget => type == "consume" ? consumeTarget : durationTargetMinute; String get label => type == "consume" ? "卡" : "分钟"; }