BlogsModel.fromMap constructor

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

This is will help us to create object from Map

Implementation

factory BlogsModel.fromMap(Map<String, dynamic> map) {
  return BlogsModel(
    kind: map['kind'],
    id: map['id'],
    name: map['name'],
    description: map['description'],
    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'],
    error: map['error'],
    posts: map['posts'] != null ? BlogPost.fromMap(map['posts']) : null,
    pages: map['pages'] != null ? BlogPage.fromMap(map['pages']) : null,
    locale: map['locale'] != null ? BlogLocale.fromMap(map['locale']) : null,
  );
}