Initial commit
This commit is contained in:
26
flutter_app/lib/models/photo.dart
Normal file
26
flutter_app/lib/models/photo.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
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};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user