-
Notifications
You must be signed in to change notification settings - Fork 2
/
article.dart
46 lines (40 loc) · 1.1 KB
/
article.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import 'dart:convert';
List<Articles> articlesFromJson(String str) => List<Articles>.from(json.decode(str)['articles'].map((x) => Articles.fromJson(Map<String,dynamic>.from(x))));
class Articles {
String ? author;
String ? title;
String ? description;
String ? url;
String ? urlToImage;
String ? publishedAt;
String ? content;
Articles({
this.author,
this.title,
this.description,
this.url,
this.urlToImage,
this.publishedAt,
this.content
});
Articles.fromJson(Map < String, dynamic > json) {
author = json['author'];
title = json['title'];
description = json['description'];
url = json['url'];
urlToImage = json['urlToImage'];
publishedAt = json['publishedAt'];
content = json['content'];
}
Map < String, dynamic > toJson() {
final Map < String, dynamic > data = < String, dynamic > {};
data['author'] = author;
data['title'] = title;
data['description'] = description;
data['url'] = url;
data['urlToImage'] = urlToImage;
data['publishedAt'] = publishedAt;
data['content'] = content;
return data;
}
}