import '../products/product_model.dart'; import '../services/result.dart'; import 'Images.dart'; class Advertisement { Advertisement({ this.archive, this.id, this.images, this.link, this.name, this.product, this.service, this.timestamp,}); Advertisement.fromJson(dynamic json) { archive = json['archive']??false; id = json['id']; if (json['images'] != null) { images = []; json['images'].forEach((v) { images?.add(Images.fromJson(v)); }); } link = json['link']; name = json['name']; product = json['product'] != null ? Product.fromJson(json['product']) : null; service = json['service'] != null ? Service.fromJson(json['service']) : null; timestamp = json['timestamp']; } bool? archive; int? id; List? images; String? link; String? name; Product? product; Service? service; int? timestamp; Map toJson() { final map = {}; map['archive'] = archive; map['id'] = id; if (images != null) { map['images'] = images?.map((v) => v.toJson()).toList(); } map['link'] = link; map['name'] = name; if (product != null) { map['product'] = product?.toJson(); } if (service != null) { map['service'] = service?.toJson(); } map['timestamp'] = timestamp; return map; } }