toMap method
This is will help us to create Map Data
Implementation
Map<String, dynamic> toMap() {
final result = <String, dynamic>{};
if (totalItems != null) {
result.addAll({'totalItems': totalItems});
}
if (selfLink != null) {
result.addAll({'selfLink': selfLink});
}
if (postComments != null) {
result.addAll(
{'postComments': postComments!.map((x) => x.toMap()).toList()});
}
return result;
}