toMap method

  1. @override
Map<String, dynamic> toMap()
override

Convert this schema to a map (without @context). Subclasses must implement this.

Implementation

@override
Map<String, dynamic> toMap() {
  return {
    '@type': articleType.value,
    'headline': headline,
    if (description != null) 'description': description,
    if (image != null) 'image': image,
    if (datePublished != null) 'datePublished': datePublished,
    if (dateModified != null) 'dateModified': dateModified,
    if (author != null) 'author': author!.toMap(),
    if (publisher != null) 'publisher': publisher!.toMap(),
    if (keywords != null && keywords!.isNotEmpty)
      'keywords': keywords!.join(', '),
    if (articleBody != null) 'articleBody': articleBody,
    if (articleSection != null) 'articleSection': articleSection,
    if (wordCount != null) 'wordCount': wordCount,
    if (url != null) 'url': url,
  };
}