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() => {
  '@type': 'BreadcrumbList',
  'itemListElement': items.asMap().entries.map((entry) {
    final index = entry.key;
    final item = entry.value;
    return {
      '@type': 'ListItem',
      'position': index + 1,
      'name': item.name,
      if (item.url != null) 'item': item.url,
    };
  }).toList(),
};