description

# Uri class Null safety

A parsed URI, such as a URL.

See also:

- URIs in the library tour
- RFC-3986

## Constructors

Uri({String? scheme, String? userInfo, String? host, int? port, String? path, Iterable<String>? pathSegments, String? query, Map<String, dynamic>? queryParameters, String? fragment})
  Creates a new URI from its components. [...]
  factory
Uri.dataFromBytes(List<int> bytes, {String mimeType: "application/octet-stream", Map<String, String>? parameters, bool percentEncoded: false})
  Creates a `data:` URI containing an encoding of `bytes`. [...]
  factory
Uri.dataFromString(String content, {String? mimeType, Encoding? encoding, Map<String, String>? parameters, bool base64: false})
  Creates a `data:` URI containing the `content` string. [...]
  factory
Uri.directory(String path, {bool? windows})
  Like Uri.file except that a non-empty URI path ends in a slash. [...]
  factory
Uri.file(String path, {bool? windows})
  Creates a new file URI from an absolute or relative file path. [...]
  factory
Uri.http(String authority, String unencodedPath, [Map<String, String>? queryParameters])
  Creates a new `http` URI from authority, path and query. [...]
  factory
Uri.https(String authority, String unencodedPath, [Map<String, String>? queryParameters])
  Creates a new `https` URI from authority, path and query. [...]
  factory

## Properties

authority → String
  Returns the authority component. [...]
  read-only
data → UriData?
  Access the structure of a `data:` URI. [...]
  read-only
fragment → String
  Returns the fragment identifier component. [...]
  read-only
hasAbsolutePath → bool
  Returns whether the URI has an absolute path (starting with '/').
  read-only
hasAuthority → bool
  Returns whether the URI has an authority component.
  read-only
hasEmptyPath → bool
  Returns whether the URI has an empty path.
  read-only
hasFragment → bool
  Returns whether the URI has a fragment part.
  read-only
hashCode → int
  Returns a hash code computed as `toString().hashCode`. [...]
  read-only, override
hasPort → bool
  Returns whether the URI has an explicit port. [...]
  read-only
hasQuery → bool
  Returns whether the URI has a query part.
  read-only
hasScheme → bool
  Returns whether the URI has a scheme component.
  read-only
host → String
  Returns the host part of the authority component. [...]
  read-only
isAbsolute → bool
  Returns whether the URI is absolute. [...]
  read-only
origin → String
  Returns the origin of the URI in the form scheme://host:port for the schemes http and https. [...]
  read-only
path → String
  Returns the path component. [...]
  read-only
pathSegments → List<String>
  Returns the URI path split into its segments. Each of the segments in the returned list have been decoded. If the path is empty the empty list will be returned. A leading slash `/` does not affect the segments returned. [...]
  read-only
port → int
  Returns the port part of the authority component. [...]
  read-only
query → String
  Returns the query component. The returned query is encoded. To get direct access to the decoded query use queryParameters. [...]
  read-only
queryParameters → Map<String, String>
  Returns the URI query split into a map according to the rules specified for FORM post in the HTML 4.01 specification section 17.13.4. Each key and value in the returned map has been decoded. If there is no query the empty map is returned. [...]
  read-only
queryParametersAll → Map<String, List<String>>
  Returns the URI query split into a map according to the rules specified for FORM post in the HTML 4.01 specification section 17.13.4. Each key and value in the returned map has been decoded. If there is no query the empty map is returned. [...]
  read-only
runtimeType → Type
  A representation of the runtime type of the object.
  read-only, inherited
scheme → String
  The scheme component of the URI. [...]
  read-only
userInfo → String
  Returns the user info part of the authority component. [...]
  read-only

## Methods

isScheme(String scheme) → bool
  Whether the scheme of this Uri is `scheme`. [...]
normalizePath() → Uri
  Returns a URI where the path has been normalized. [...]
noSuchMethod(Invocation invocation) → dynamic
  Invoked when a non-existent method or property is accessed. [...]
  inherited
removeFragment() → Uri
  Returns a `Uri` that differs from this only in not having a fragment. [...]
replace({String? scheme, String? userInfo, String? host, int? port, String? path, Iterable<String>? pathSegments, String? query, Map<String, dynamic>? queryParameters, String? fragment}) → Uri
  Returns a new `Uri` based on this one, but with some parts replaced. [...]
resolve(String reference) → Uri
  Resolve `reference` as an URI relative to `this`. [...]
resolveUri(Uri reference) → Uri
  Resolve `reference` as an URI relative to `this`. [...]
toFilePath({bool? windows}) → String
  Returns the file path from a file URI. [...]
toString() → String
  Returns the normalized string representation of the URI.
  override

## Operators

operator ==(Object other) → bool
  A URI is equal to another URI with the same normalized representation.
  override

## Static Properties

base → Uri
  Returns the natural base URI for the current platform. [...]
  read-only

## Static Methods

decodeComponent(String encodedComponent) → String
  Decodes the percent-encoding in `encodedComponent`. [...]
decodeFull(String uri) → String
  Decodes the percent-encoding in `uri`. [...]
decodeQueryComponent(String encodedComponent, {Encoding encoding: utf8}) → String
  Decodes the percent-encoding in `encodedComponent`, converting pluses to spaces. [...]
encodeComponent(String component) → String
  Encode the string `component` using percent-encoding to make it safe for literal use as a URI component. [...]
encodeFull(String uri) → String
  Encode the string `uri` using percent-encoding to make it safe for literal use as a full URI. [...]
encodeQueryComponent(String component, {Encoding encoding: utf8}) → String
  Encode the string `component` according to the HTML 4.01 rules for encoding the posting of a HTML form as a query string component. [...]
parse(String uri, [int start = 0, int? end]) → Uri
  Creates a new `Uri` object by parsing a URI string. [...]
parseIPv4Address(String host) → List<int>
  Parse the `host` as an IP version 4 (IPv4) address, returning the address as a list of 4 bytes in network byte order (big endian). [...]
parseIPv6Address(String host, [int start = 0, int? end]) → List<int>
  Parse the `host` as an IP version 6 (IPv6) address, returning the address as a list of 16 bytes in network byte order (big endian). [...]
splitQueryString(String query, {Encoding encoding: utf8}) → Map<String, String>
  Returns the `query` split into a map according to the rules specified for FORM post in the HTML 4.01 specification section 17.13.4. Each key and value in the returned map has been decoded. If the `query` is the empty string an empty map is returned. [...]
tryParse(String uri, [int start = 0, int? end]) → Uri?
  Creates a new `Uri` object by parsing a URI string. [...]