toJson method

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

Converts this class object into a JSON value.

Implementation

@override
Map<String, dynamic> toJson() {
  final result = {
    "href": href.toString(),
    ...additionalFields,
  };

  final anchor = this.anchor;
  if (anchor != null) {
    result["anchor"] = anchor.toString();
  }

  final keyValuePairs = [
    ("type", type),
    ("rel", rel),
    ("sizes", sizes),
    ("hreflang", hreflang),
  ];

  for (final (key, value) in keyValuePairs) {
    if (value != null) {
      result[key] = value;
    }
  }

  return result;
}