Last active
July 31, 2019 14:28
-
-
Save agarasul/9f080a6caadf97f539d72e16e0ffd0fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class News { | |
String status; | |
String error; | |
int totalResults; | |
List<Article> articles; | |
News({this.status, this.articles}); | |
News.fromJson(Map<String, dynamic> newsJson) | |
: status = newsJson['status'], | |
articles = List.from(newsJson['articles']) | |
.map((article) => Article.fromJson(article)) | |
.toList(), | |
totalResults = newsJson['totalResults'], | |
error = newsJson['error']; | |
} | |
class Article { | |
Source source; | |
String author; | |
String title; | |
String description; | |
String urlToImage; | |
String url; | |
String publishedAt; | |
String content; | |
Article.fromJson(Map<String, dynamic> articleJson) | |
: source = Source.fromJson(articleJson['source']), | |
author = articleJson['author'], | |
title = articleJson['title'], | |
description = articleJson['description'], | |
urlToImage = articleJson['urlToImage'], | |
url = articleJson['url'], | |
publishedAt = articleJson['publishedAt'], | |
content = articleJson['content']; | |
} | |
class Source { | |
String id; | |
String name; | |
Source.fromJson(Map<String, dynamic> sourceJson) | |
: id = sourceJson['id'], | |
name = sourceJson['name']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment