fromJson static method
Returns a new APIComment instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static APIComment? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
assert(json.containsKey(r'id'), 'Required key "APIComment[id]" is missing from JSON.');
assert(json[r'id'] != null, 'Required key "APIComment[id]" has a null value in JSON.');
assert(json.containsKey(r'approved'), 'Required key "APIComment[approved]" is missing from JSON.');
assert(json[r'approved'] != null, 'Required key "APIComment[approved]" has a null value in JSON.');
assert(json.containsKey(r'comment'), 'Required key "APIComment[comment]" is missing from JSON.');
assert(json[r'comment'] != null, 'Required key "APIComment[comment]" has a null value in JSON.');
assert(json.containsKey(r'commentHTML'), 'Required key "APIComment[commentHTML]" is missing from JSON.');
assert(json[r'commentHTML'] != null, 'Required key "APIComment[commentHTML]" has a null value in JSON.');
assert(json.containsKey(r'commenterName'), 'Required key "APIComment[commenterName]" is missing from JSON.');
assert(json[r'commenterName'] != null, 'Required key "APIComment[commenterName]" has a null value in JSON.');
assert(json.containsKey(r'date'), 'Required key "APIComment[date]" is missing from JSON.');
assert(json.containsKey(r'locale'), 'Required key "APIComment[locale]" is missing from JSON.');
assert(json.containsKey(r'tenantId'), 'Required key "APIComment[tenantId]" is missing from JSON.');
assert(json[r'tenantId'] != null, 'Required key "APIComment[tenantId]" has a null value in JSON.');
assert(json.containsKey(r'url'), 'Required key "APIComment[url]" is missing from JSON.');
assert(json[r'url'] != null, 'Required key "APIComment[url]" has a null value in JSON.');
assert(json.containsKey(r'urlId'), 'Required key "APIComment[urlId]" is missing from JSON.');
assert(json[r'urlId'] != null, 'Required key "APIComment[urlId]" has a null value in JSON.');
assert(json.containsKey(r'verified'), 'Required key "APIComment[verified]" is missing from JSON.');
assert(json[r'verified'] != null, 'Required key "APIComment[verified]" has a null value in JSON.');
return true;
}());
return APIComment(
id: mapValueOfType<String>(json, r'id')!,
aiDeterminedSpam: mapValueOfType<bool>(json, r'aiDeterminedSpam'),
anonUserId: mapValueOfType<String>(json, r'anonUserId'),
approved: mapValueOfType<bool>(json, r'approved')!,
avatarSrc: mapValueOfType<String>(json, r'avatarSrc'),
badges: CommentUserBadgeInfo.listFromJson(json[r'badges']),
comment: mapValueOfType<String>(json, r'comment')!,
commentHTML: mapValueOfType<String>(json, r'commentHTML')!,
commenterEmail: mapValueOfType<String>(json, r'commenterEmail'),
commenterLink: mapValueOfType<String>(json, r'commenterLink'),
commenterName: mapValueOfType<String>(json, r'commenterName')!,
date: mapValueOfType<double>(json, r'date'),
displayLabel: mapValueOfType<String>(json, r'displayLabel'),
domain: mapValueOfType<String>(json, r'domain'),
externalId: mapValueOfType<String>(json, r'externalId'),
externalParentId: mapValueOfType<String>(json, r'externalParentId'),
expireAt: mapDateTime(json, r'expireAt', r''),
feedbackIds: json[r'feedbackIds'] is Iterable
? (json[r'feedbackIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
flagCount: mapValueOfType<int>(json, r'flagCount'),
fromProductId: mapValueOfType<int>(json, r'fromProductId'),
hasCode: mapValueOfType<bool>(json, r'hasCode'),
hasImages: mapValueOfType<bool>(json, r'hasImages'),
hasLinks: mapValueOfType<bool>(json, r'hasLinks'),
hashTags: CommentUserHashTagInfo.listFromJson(json[r'hashTags']),
isByAdmin: mapValueOfType<bool>(json, r'isByAdmin'),
isByModerator: mapValueOfType<bool>(json, r'isByModerator'),
isDeleted: mapValueOfType<bool>(json, r'isDeleted'),
isDeletedUser: mapValueOfType<bool>(json, r'isDeletedUser'),
isPinned: mapValueOfType<bool>(json, r'isPinned'),
isLocked: mapValueOfType<bool>(json, r'isLocked'),
isSpam: mapValueOfType<bool>(json, r'isSpam'),
localDateHours: mapValueOfType<int>(json, r'localDateHours'),
localDateString: mapValueOfType<String>(json, r'localDateString'),
locale: mapValueOfType<String>(json, r'locale'),
mentions: CommentUserMentionInfo.listFromJson(json[r'mentions']),
meta: APICommentBaseMeta.fromJson(json[r'meta']),
moderationGroupIds: json[r'moderationGroupIds'] is Iterable
? (json[r'moderationGroupIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
notificationSentForParent: mapValueOfType<bool>(json, r'notificationSentForParent'),
notificationSentForParentTenant: mapValueOfType<bool>(json, r'notificationSentForParentTenant'),
pageTitle: mapValueOfType<String>(json, r'pageTitle'),
parentId: mapValueOfType<String>(json, r'parentId'),
rating: mapValueOfType<double>(json, r'rating'),
reviewed: mapValueOfType<bool>(json, r'reviewed'),
tenantId: mapValueOfType<String>(json, r'tenantId')!,
url: mapValueOfType<String>(json, r'url')!,
urlId: mapValueOfType<String>(json, r'urlId')!,
urlIdRaw: mapValueOfType<String>(json, r'urlIdRaw'),
userId: mapValueOfType<String>(json, r'userId'),
verified: mapValueOfType<bool>(json, r'verified')!,
verifiedDate: mapDateTime(json, r'verifiedDate', r''),
votes: mapValueOfType<int>(json, r'votes'),
votesDown: mapValueOfType<int>(json, r'votesDown'),
votesUp: mapValueOfType<int>(json, r'votesUp'),
);
}
return null;
}