toMap method

Map<String, dynamic> toMap()

This is will help us to create Map Data

Implementation

Map<String, dynamic> toMap() {
  final result = <String, dynamic>{};

  if (kind != null) {
    result.addAll({'kind': kind});
  }
  if (id != null) {
    result.addAll({'id': id});
  }
  if (name != null) {
    result.addAll({'name': name});
  }
  if (description != null) {
    result.addAll({'description': description});
  }
  if (published != null) {
    result.addAll({'published': published!.millisecondsSinceEpoch});
  }
  if (updated != null) {
    result.addAll({'updated': updated!.millisecondsSinceEpoch});
  }
  if (url != null) {
    result.addAll({'url': url});
  }
  if (selfLink != null) {
    result.addAll({'selfLink': selfLink});
  }
  if (error != null) {
    result.addAll({'error': error});
  }
  if (posts != null) {
    result.addAll({'posts': posts!.toMap()});
  }
  if (pages != null) {
    result.addAll({'pages': pages!.toMap()});
  }
  if (locale != null) {
    result.addAll({'locale': locale!.toMap()});
  }

  return result;
}