PostItemModel.fromMap constructor

PostItemModel.fromMap(
  1. Map<String, dynamic> map
)

This is will help us to create object from Map

Implementation

factory PostItemModel.fromMap(Map<String, dynamic> map) {
  return PostItemModel(
    kind: map['kind'],
    id: map['id'],
    blogId: map['blog']['id'],
    published: map['published'] != null
        ? DateTime.parse(map[
            'published']) //DateTime.fromMillisecondsSinceEpoch(map['published'])
        : null,
    updated: map['updated'] != null
        ? DateTime.parse(map[
            'updated']) //DateTime.fromMillisecondsSinceEpoch(map['updated'])
        : null,
    url: map['url'],
    selfLink: map['selfLink'],
    title: map['title'],
    content: map['content'],
    author: map['author'] != null ? Author.fromMap(map['author']) : null,
    replies: map['replies'] != null ? Replies.fromMap(map['replies']) : null,
    etag: map['etag'],
    labels: map['labels'] != null ? List<String>.from(map['labels']) : null,
  );
}