Link.fromJson constructor

Link.fromJson(
  1. Map<String, dynamic> json,
  2. PrefixMapping prefixMapping
)

Creates a new Link from a json object.

Implementation

factory Link.fromJson(
  Map<String, dynamic> json,
  PrefixMapping prefixMapping,
) {
  final Set<String> parsedFields = {};

  final href = json.parseRequiredUriField("href", parsedFields);
  final type = json.parseField<String>("type", parsedFields);
  final rel = json.parseField<String>("rel", parsedFields);
  final anchor = json.parseUriField("anchor", parsedFields);
  final sizes = json.parseField<String>("sizes", parsedFields);
  final hreflang =
      json.parseArrayField<String>("hreflang", parsedFields: parsedFields);
  final additionalFields =
      json.parseAdditionalFields(prefixMapping, parsedFields);

  return Link(
    href,
    type: type,
    rel: rel,
    anchor: anchor,
    sizes: sizes,
    hreflang: hreflang,
    additionalFields: additionalFields,
  );
}