27 lines
584 B
Dart
27 lines
584 B
Dart
class Photo {
|
|
final String id;
|
|
final String url;
|
|
final String caption;
|
|
final bool active;
|
|
|
|
const Photo({
|
|
required this.id,
|
|
required this.url,
|
|
required this.caption,
|
|
required this.active,
|
|
});
|
|
|
|
factory Photo.fromJson(Map<String, dynamic> json) {
|
|
return Photo(
|
|
id: json["_id"] as String? ?? "",
|
|
url: json["url"] as String? ?? "",
|
|
caption: json["caption"] as String? ?? "",
|
|
active: json["active"] as bool? ?? true,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {"url": url, "caption": caption, "active": active};
|
|
}
|
|
}
|