import 'package:sport/bean/sport_target_day.dart'; import 'package:sport/bean/sport_target_record.dart'; import 'sport_target.dart'; class SportTargetIndex { SportTarget target; SportTargetDay today; List records; List rewards; SportTargetIndex({this.target, this.today, this.records, this.rewards}); SportTargetIndex.fromJson(Map json) { target = json['target'] != null ? new SportTarget.fromJson(json['target']) : null; today = json['today'] != null ? new SportTargetDay.fromJson(json['today']) : null; if (json['records'] != null) { records = new List(); json['records'].forEach((v) { records.add(new SportTargetRecord.fromJson(v)); }); } if (json['rewards'] != null) { rewards = new List(); json['rewards'].forEach((v) { rewards.add(new Rewards.fromJson(v)); }); } } Map toJson() { final Map data = new Map(); if (this.target != null) { data['target'] = this.target.toJson(); } if (this.today != null) { data['today'] = this.today.toJson(); } if (this.records != null) { data['records'] = this.records.map((v) => v.toJson()).toList(); } if (this.rewards != null) { data['rewards'] = this.rewards.map((v) => v.toJson()).toList(); } return data; } } class Rewards { int id; int fullMonth; int score; String status; int days; Rewards({this.id, this.fullMonth, this.score, this.status, this.days}); Rewards.fromJson(Map json) { id = json['id']; fullMonth = json['full_month']; score = json['score']; status = json['status']; days = json['days']; } Map toJson() { final Map data = new Map(); data['id'] = this.id; data['full_month'] = this.fullMonth; data['score'] = this.score; data['status'] = this.status; data['days'] = this.days; return data; } }