Line data Source code
1 : import 'package:equatable/equatable.dart';
2 : import 'package:json_annotation/json_annotation.dart';
3 :
4 : part 'open_graph_data.g.dart';
5 :
6 : ///
7 : @JsonSerializable(createToJson: true)
8 : class OpenGraphData extends Equatable {
9 : ///
10 4 : const OpenGraphData({
11 : this.title,
12 : this.type,
13 : this.url,
14 : this.site,
15 : this.siteName,
16 : this.description,
17 : this.determiner,
18 : this.locale,
19 : this.images,
20 : this.videos,
21 : this.audios,
22 : });
23 :
24 : /// Create a new instance from a json
25 3 : factory OpenGraphData.fromJson(Map<String, dynamic> json) =>
26 3 : _$OpenGraphDataFromJson(json);
27 :
28 : ///
29 : final String? title;
30 :
31 : ///
32 : final String? type;
33 :
34 : ///
35 : final String? url;
36 :
37 : ///
38 : final String? site;
39 :
40 : ///
41 : final String? siteName;
42 :
43 : ///
44 : final String? description;
45 :
46 : ///
47 : final String? determiner;
48 :
49 : ///
50 : final String? locale;
51 :
52 : ///
53 : final List<Image>? images;
54 :
55 : ///
56 : final List<Video>? videos;
57 :
58 : ///
59 : final List<Audio>? audios;
60 :
61 1 : @override
62 1 : List<Object?> get props => [
63 1 : title,
64 1 : type,
65 1 : url,
66 1 : site,
67 1 : siteName,
68 1 : description,
69 1 : determiner,
70 1 : locale,
71 1 : images,
72 1 : videos,
73 1 : audios,
74 : ];
75 :
76 : /// Serialize to json
77 2 : Map<String, dynamic> toJson() => _$OpenGraphDataToJson(this);
78 : }
79 :
80 : ///
81 : @JsonSerializable(createToJson: true)
82 : class Image extends Equatable {
83 : ///
84 4 : const Image({
85 : this.image,
86 : this.url,
87 : this.secureUrl,
88 : this.width,
89 : this.height,
90 : this.type,
91 : this.alt,
92 : });
93 :
94 : /// Create a new instance from a json
95 6 : factory Image.fromJson(Map<String, dynamic> json) => _$ImageFromJson(json);
96 :
97 : ///
98 : final String? image;
99 :
100 : ///
101 : final String? url;
102 :
103 : ///
104 : final String? secureUrl;
105 :
106 : ///
107 : final String? width;
108 :
109 : ///
110 : final String? height;
111 :
112 : ///
113 : final String? type;
114 :
115 : ///
116 : final String? alt;
117 :
118 1 : @override
119 1 : List<Object?> get props => [
120 1 : image,
121 1 : url,
122 1 : secureUrl,
123 1 : width,
124 1 : height,
125 1 : type,
126 1 : alt,
127 : ];
128 :
129 : /// Serialize to json
130 2 : Map<String, dynamic> toJson() => _$ImageToJson(this);
131 : }
132 :
133 : ///
134 : @JsonSerializable(createToJson: true)
135 : class Video extends Equatable {
136 : ///
137 4 : const Video({
138 : this.image,
139 : this.url,
140 : this.secureUrl,
141 : this.width,
142 : this.height,
143 : this.type,
144 : this.alt,
145 : });
146 :
147 : /// Create a new instance from a json
148 6 : factory Video.fromJson(Map<String, dynamic> json) => _$VideoFromJson(json);
149 :
150 : ///
151 : final String? image;
152 :
153 : ///
154 : final String? url;
155 :
156 : ///
157 : final String? secureUrl;
158 :
159 : ///
160 : final String? width;
161 :
162 : ///
163 : final String? height;
164 :
165 : ///
166 : final String? type;
167 :
168 : ///
169 : final String? alt;
170 :
171 1 : @override
172 1 : List<Object?> get props => [
173 1 : image,
174 1 : url,
175 1 : secureUrl,
176 1 : width,
177 1 : height,
178 1 : type,
179 1 : alt,
180 : ];
181 :
182 : /// Serialize to json
183 2 : Map<String, dynamic> toJson() => _$VideoToJson(this);
184 : }
185 :
186 : ///
187 : @JsonSerializable(createToJson: true)
188 : class Audio extends Equatable {
189 : ///
190 4 : const Audio({
191 : this.audio,
192 : this.url,
193 : this.secureUrl,
194 : this.type,
195 : });
196 :
197 : /// Create a new instance from a json
198 6 : factory Audio.fromJson(Map<String, dynamic> json) => _$AudioFromJson(json);
199 2 : Map<String, dynamic> toJson() => _$AudioToJson(this);
200 :
201 : ///
202 : final String? audio;
203 :
204 : ///
205 : final String? url;
206 :
207 : ///
208 : final String? secureUrl;
209 :
210 : ///
211 : final String? type;
212 :
213 1 : @override
214 1 : List<Object?> get props => [
215 1 : audio,
216 1 : url,
217 1 : secureUrl,
218 1 : type,
219 : ];
220 : }
|