import 'package:flustars/flustars.dart'; import 'package:aku_community/model/common/img_model.dart'; class ActivityItemModel { int id; String title; String location; int status; String registrationStartTime; String registrationEndTime; List imgUrls; List headImgURls; DateTime get begin => DateUtil.getDateTime(registrationStartTime); DateTime get end => DateUtil.getDateTime(registrationEndTime); ActivityItemModel( {this.id, this.title, this.location, this.status, this.registrationStartTime, this.registrationEndTime, this.imgUrls, this.headImgURls}); ActivityItemModel.fromJson(Map json) { id = json['id']; title = json['title']; location = json['location']; status = json['status']; registrationStartTime = json['registrationStartTime']; registrationEndTime = json['registrationEndTime']; if (json['imgUrls'] != null) { imgUrls = []; json['imgUrls'].forEach((v) { imgUrls.add(new ImgModel.fromJson(v)); }); } else { imgUrls = []; } if (json['headImgURls'] != null) { headImgURls = []; json['headImgURls'].forEach((v) { headImgURls.add(new ImgModel.fromJson(v)); }); } else { headImgURls = []; } } Map toJson() { final Map data = new Map(); data['id'] = this.id; data['title'] = this.title; data['location'] = this.location; data['status'] = this.status; data['registrationStartTime'] = this.registrationStartTime; data['registrationEndTime'] = this.registrationEndTime; if (this.imgUrls != null) { data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); } if (this.headImgURls != null) { data['headImgURls'] = this.headImgURls.map((v) => v.toJson()).toList(); } return data; } }