79 lines
2.1 KiB
Dart
79 lines
2.1 KiB
Dart
import "dart:convert";
|
|
|
|
class GalleryItem {
|
|
final String id;
|
|
final String displayName;
|
|
final String handle;
|
|
final String content;
|
|
final bool verified;
|
|
final int timestamp;
|
|
final String? avatarImageB64;
|
|
final String? postImageB64;
|
|
final String replies;
|
|
final String retweets;
|
|
final String likes;
|
|
final String views;
|
|
final int createdAt;
|
|
final String? title;
|
|
|
|
GalleryItem({
|
|
required this.id,
|
|
required this.displayName,
|
|
required this.handle,
|
|
required this.content,
|
|
required this.verified,
|
|
required this.timestamp,
|
|
this.avatarImageB64,
|
|
this.postImageB64,
|
|
required this.replies,
|
|
required this.retweets,
|
|
required this.likes,
|
|
required this.views,
|
|
required this.createdAt,
|
|
this.title,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
"id": id,
|
|
"displayName": displayName,
|
|
"handle": handle,
|
|
"content": content,
|
|
"verified": verified,
|
|
"timestamp": timestamp,
|
|
"avatarImageB64": avatarImageB64,
|
|
"postImageB64": postImageB64,
|
|
"replies": replies,
|
|
"retweets": retweets,
|
|
"likes": likes,
|
|
"views": views,
|
|
"createdAt": createdAt,
|
|
"title": title,
|
|
};
|
|
}
|
|
|
|
factory GalleryItem.fromJson(Map<String, dynamic> json) {
|
|
return GalleryItem(
|
|
id: json["id"] as String,
|
|
displayName: json["displayName"] as String? ?? "",
|
|
handle: json["handle"] as String? ?? "",
|
|
content: json["content"] as String? ?? "",
|
|
verified: json["verified"] as bool? ?? false,
|
|
timestamp: json["timestamp"] as int? ?? 0,
|
|
avatarImageB64: json["avatarImageB64"] as String?,
|
|
postImageB64: json["postImageB64"] as String?,
|
|
replies: json["replies"] as String? ?? "",
|
|
retweets: json["retweets"] as String? ?? "",
|
|
likes: json["likes"] as String? ?? "",
|
|
views: json["views"] as String? ?? "",
|
|
createdAt: json["createdAt"] as int? ?? 0,
|
|
title: json["title"] as String?,
|
|
);
|
|
}
|
|
|
|
String toJsonString() => jsonEncode(toJson());
|
|
|
|
factory GalleryItem.fromJsonString(String s) =>
|
|
GalleryItem.fromJson(jsonDecode(s) as Map<String, dynamic>);
|
|
}
|