Created
March 14, 2021 10:05
-
-
Save mukhtharcm/0155a670c5dc416556201d1e2483dfed to your computer and use it in GitHub Desktop.
Gist for Blogger api in Flutter Post
This file contains hidden or 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 PostList { | |
String kind; | |
String nextPageToken; | |
String prevPageToken; | |
List<Items> items; | |
PostList({this.kind, this.nextPageToken, this.prevPageToken, this.items}); | |
PostList.fromJson(Map<String, dynamic> json) { | |
kind = json['kind']; | |
nextPageToken = json['nextPageToken']; | |
prevPageToken = json['prevPageToken']; | |
if (json['items'] != null) { | |
items = new List<Items>(); | |
json['items'].forEach((v) { | |
items.add(new Items.fromJson(v)); | |
}); | |
} | |
} | |
Map<String, dynamic> toJson() { | |
final Map<String, dynamic> data = new Map<String, dynamic>(); | |
data['kind'] = this.kind; | |
data['nextPageToken'] = this.nextPageToken; | |
data['prevPageToken'] = this.prevPageToken; | |
if (this.items != null) { | |
data['items'] = this.items.map((v) => v.toJson()).toList(); | |
} | |
return data; | |
} | |
} | |
class Items { | |
String kind; | |
String id; | |
Blog blog; | |
String published; | |
String updated; | |
String url; | |
String selfLink; | |
String title; | |
String content; | |
Author author; | |
Replies replies; | |
Items( | |
{this.kind, | |
this.id, | |
this.blog, | |
this.published, | |
this.updated, | |
this.url, | |
this.selfLink, | |
this.title, | |
this.content, | |
this.author, | |
this.replies}); | |
Items.fromJson(Map<String, dynamic> json) { | |
kind = json['kind']; | |
id = json['id']; | |
blog = json['blog'] != null ? new Blog.fromJson(json['blog']) : null; | |
published = json['published']; | |
updated = json['updated']; | |
url = json['url']; | |
selfLink = json['selfLink']; | |
title = json['title']; | |
content = json['content']; | |
author = | |
json['author'] != null ? new Author.fromJson(json['author']) : null; | |
replies = | |
json['replies'] != null ? new Replies.fromJson(json['replies']) : null; | |
} | |
Map<String, dynamic> toJson() { | |
final Map<String, dynamic> data = new Map<String, dynamic>(); | |
data['kind'] = this.kind; | |
data['id'] = this.id; | |
if (this.blog != null) { | |
data['blog'] = this.blog.toJson(); | |
} | |
data['published'] = this.published; | |
data['updated'] = this.updated; | |
data['url'] = this.url; | |
data['selfLink'] = this.selfLink; | |
data['title'] = this.title; | |
data['content'] = this.content; | |
if (this.author != null) { | |
data['author'] = this.author.toJson(); | |
} | |
if (this.replies != null) { | |
data['replies'] = this.replies.toJson(); | |
} | |
return data; | |
} | |
} | |
class Blog { | |
String id; | |
Blog({this.id}); | |
Blog.fromJson(Map<String, dynamic> json) { | |
id = json['id']; | |
} | |
Map<String, dynamic> toJson() { | |
final Map<String, dynamic> data = new Map<String, dynamic>(); | |
data['id'] = this.id; | |
return data; | |
} | |
} | |
class Author { | |
String id; | |
String displayName; | |
String url; | |
Image image; | |
Author({this.id, this.displayName, this.url, this.image}); | |
Author.fromJson(Map<String, dynamic> json) { | |
id = json['id']; | |
displayName = json['displayName']; | |
url = json['url']; | |
image = json['image'] != null ? new Image.fromJson(json['image']) : null; | |
} | |
Map<String, dynamic> toJson() { | |
final Map<String, dynamic> data = new Map<String, dynamic>(); | |
data['id'] = this.id; | |
data['displayName'] = this.displayName; | |
data['url'] = this.url; | |
if (this.image != null) { | |
data['image'] = this.image.toJson(); | |
} | |
return data; | |
} | |
} | |
class Image { | |
String url; | |
Image({this.url}); | |
Image.fromJson(Map<String, dynamic> json) { | |
url = json['url']; | |
} | |
Map<String, dynamic> toJson() { | |
final Map<String, dynamic> data = new Map<String, dynamic>(); | |
data['url'] = this.url; | |
return data; | |
} | |
} | |
class Replies { | |
String totalItems; | |
String selfLink; | |
Replies({this.totalItems, this.selfLink}); | |
Replies.fromJson(Map<String, dynamic> json) { | |
totalItems = json['totalItems']; | |
selfLink = json['selfLink']; | |
} | |
Map<String, dynamic> toJson() { | |
final Map<String, dynamic> data = new Map<String, dynamic>(); | |
data['totalItems'] = this.totalItems; | |
data['selfLink'] = this.selfLink; | |
return data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment