fromURI static method

ResourceContent? fromURI(
  1. Object? uri, [
  2. String? content
])

Constructor with Resource from uri.

content in case of content/body is already resolved.

Implementation

static ResourceContent? fromURI(Object? uri, [String? content]) {
  if (uri == null && content == null) return null;

  if (uri is Uri) {
    return ResourceContent(Resource(uri), content);
  } else if (uri is String) {
    return ResourceContent(Resource(uri), content);
  } else if (uri is ResourceContent) {
    return ResourceContent(Resource(uri.uri), content);
  } else {
    var url = uri.toString();
    return ResourceContent(Resource(url), content);
  }
}