Skip to content

Instantly share code, notes, and snippets.

@ashishrawat2911
Last active December 6, 2018 05:30
Show Gist options
  • Save ashishrawat2911/c5eeb2f47a7b24b437670f1aeacf81ef to your computer and use it in GitHub Desktop.
Save ashishrawat2911/c5eeb2f47a7b24b437670f1aeacf81ef to your computer and use it in GitHub Desktop.
class Article {
Source source;
String author;
String title;
String description;
String url;
String urlToImage;
String publishedAt;
String content;
Article(
{this.source,
this.author,
this.title,
this.description,
this.url,
this.urlToImage,
this.publishedAt,
this.content});
factory Article.fromJson(Map<String, dynamic> json) {
return Article(
source: Source.fromJson(json["source"]),
author: json["author"],
title: json["title"],
description: json["description"],
url: json["url"],
urlToImage: json["urlToImage"],
publishedAt: json["publishedAt"],
content: json["content"]);
}
}
class Source {
String id;
String name;
Source({this.id, this.name});
factory Source.fromJson(Map<String, dynamic> json) {
return Source(
id: json["id"] as String,
name: json["name"] as String,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment