fromJson static method
Returns a new Comment instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Comment? 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 "Comment[id]" is missing from JSON.');
assert(json[r'id'] != null, 'Required key "Comment[id]" has a null value in JSON.');
assert(json.containsKey(r'noteId'), 'Required key "Comment[noteId]" is missing from JSON.');
assert(json[r'noteId'] != null, 'Required key "Comment[noteId]" has a null value in JSON.');
assert(json.containsKey(r'body'), 'Required key "Comment[body]" is missing from JSON.');
assert(json[r'body'] != null, 'Required key "Comment[body]" has a null value in JSON.');
assert(json.containsKey(r'createdAt'), 'Required key "Comment[createdAt]" is missing from JSON.');
assert(json[r'createdAt'] != null, 'Required key "Comment[createdAt]" has a null value in JSON.');
assert(json.containsKey(r'updatedAt'), 'Required key "Comment[updatedAt]" is missing from JSON.');
assert(json[r'updatedAt'] != null, 'Required key "Comment[updatedAt]" has a null value in JSON.');
assert(json.containsKey(r'author'), 'Required key "Comment[author]" is missing from JSON.');
assert(json[r'author'] != null, 'Required key "Comment[author]" has a null value in JSON.');
return true;
}());
return Comment(
id: mapValueOfType<String>(json, r'id')!,
noteId: mapValueOfType<String>(json, r'noteId')!,
parentCommentId: mapValueOfType<String>(json, r'parentCommentId'),
blockId: mapValueOfType<String>(json, r'blockId'),
body: mapValueOfType<String>(json, r'body')!,
createdAt: mapDateTime(json, r'createdAt', r'')!,
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
author: CommentAuthor.fromJson(json[r'author'])!,
);
}
return null;
}