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': businessType?.value ?? 'LocalBusiness',
    'name': name,
    if (description != null) 'description': description,
    if (url != null) 'url': url,
    if (image != null) 'image': image,
    if (telephone != null) 'telephone': telephone,
    if (email != null) 'email': email,
    if (address != null) 'address': address!.toMap(),
    if (geo != null) 'geo': geo!.toMap(),
    if (openingHours != null && openingHours!.isNotEmpty)
      'openingHoursSpecification': openingHours!
          .map((o) => o.toMap())
          .toList(),
    if (priceRange != null) 'priceRange': priceRange,
    if (sameAs != null && sameAs!.isNotEmpty) 'sameAs': sameAs,
    if (menu != null) 'menu': menu,
    if (servesCuisine != null && servesCuisine!.isNotEmpty)
      'servesCuisine': servesCuisine,
    if (currenciesAccepted != null) 'currenciesAccepted': currenciesAccepted,
    if (paymentAccepted != null) 'paymentAccepted': paymentAccepted,
  };
}