resolvedHref property

Uri resolvedHref

Resolves all _userProvidedUriVariables in this Form and returns the resulting Uri.

Implementation

Uri get resolvedHref {
  final hrefUriVariables = _filterUriVariables(href);

  if (hrefUriVariables.isEmpty) {
    return href;
  }

  final Map<String, Object> affordanceUriVariables = {
    ..._thingDescription.uriVariables ?? {},
    ..._interactionAffordance.uriVariables ?? {},
  };

  final userProvidedUriVariables = _userProvidedUriVariables;
  if (userProvidedUriVariables != null) {
    _validateUriVariables(
      hrefUriVariables,
      affordanceUriVariables,
      userProvidedUriVariables,
    );
  }

  // As "{" and "}" are "percent encoded" due to Uri.parse(), we need to
  // revert the encoding first before we can insert the values.
  final decodedHref = Uri.decodeFull(href.toString());

  final expandedHref =
      UriTemplate(decodedHref).expand(userProvidedUriVariables ?? {});
  return Uri.parse(expandedHref);
}