Created
April 2, 2018 12:17
-
-
Save wilburx9/988da34565111e697b4e95667f6f19d1 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 Post { | |
String title; | |
String summary; | |
String thumbUrl; | |
int timeStamp; | |
String url; | |
Post(this.title, this.summary, this.thumbUrl, this.timeStamp, this.url); | |
static Post getPostFrmJSONPost(dynamic jsonObject) { | |
String title = jsonObject['title']; | |
String url = jsonObject['url']; | |
String summary = jsonObject['abstract']; | |
List multiMediaList = jsonObject['multimedia']; | |
// We want an average-quality image or nothing | |
String thumbUrl = multiMediaList.length > 4? multiMediaList[3]['url'] : ""; | |
int timeStamp = DateTime.parse(jsonObject['created_date']).millisecondsSinceEpoch; | |
return new Post(title, summary, thumbUrl, timeStamp, url); | |
} | |
@override | |
String toString() { | |
return "title = $title; summary = $summary; thumgnail = $thumbUrl; " | |
"timeStamp = $timeStamp; url = $url"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment