WebUri class
Class that implements the Uri interface to maintain also the raw string value used by Uri.parse.
This class is used because some strings coming from the native platform side are not parsed correctly or could lose letter case information, so rawValue can be used as a fallback value.
Examples:
// InAppWebView example
InAppWebView(
initialUrlRequest:
URLRequest(url: WebUri('https://flutter.dev'))
)
// example of letter case difference
final uri = WebUri('scheme://customHostValue', forceToStringRawValue: false);
print(uri.rawValue); // scheme://customHostValue
print(uri.isValidUri); // true
print(uri.uriValue.toString()); // scheme://customhostvalue
print(uri.toString()); // scheme://customhostvalue
uri.forceToStringRawValue = true;
print(uri.toString()); // scheme://customHostValue
// example of a not valid URI
// Uncaught Error: FormatException: Invalid port (at character 14)
final invalidUri = WebUri('intent://not:valid_uri');
print(invalidUri.rawValue); // intent://not:valid_uri
print(invalidUri.isValidUri); // false
print(invalidUri.uriValue.toString()); // ''
print(invalidUri.toString()); // intent://not:valid_uri
- Implemented types
Constructors
- WebUri(String source, {bool forceToStringRawValue = false})
-
Initialize a WebUri using a raw string value.
In this case, uriValue
.toString()
and rawValue could not have the same value. - WebUri.uri(Uri uri)
-
Initialize a WebUri using an Uri instance.
In this case, uriValue
.toString()
and rawValue will have the same value.
Properties
-
The authority component.
no setteroverride
- data → UriData?
-
Access the structure of a
data:
URI.no setteroverride - forceToStringRawValue ↔ bool
-
Whether to force the usage of rawValue when calling toString or not.
Because toString is used to send URI strings to the native platform side,
this flag is useful when you want to send rawValue instead of uriValue
.toString()
.getter/setter pair - fragment → String
-
The fragment identifier component.
no setteroverride
- hasAbsolutePath → bool
-
Whether the URI has an absolute path (starting with '/').
no setteroverride
- hasAuthority → bool
-
Whether the URI has an authority component.
no setteroverride
- hasEmptyPath → bool
-
Whether the URI has an empty path.
no setteroverride
- hasFragment → bool
-
Whether the URI has a fragment part.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setteroverride
- hasPort → bool
-
Whether the URI has an explicit port.
no setteroverride
- hasQuery → bool
-
Whether the URI has a query part.
no setteroverride
- hasScheme → bool
-
Whether the URI has a scheme component.
no setteroverride
- host → String
-
The host part of the authority component.
no setteroverride
- isAbsolute → bool
-
Whether the URI is absolute.
no setteroverride
- isValidUri → bool
-
true
if rawValue has been parsed correctly, otherwisefalse
.no setter - origin → String
-
Returns the origin of the URI in the form scheme://host:port for the
schemes http and https.
no setteroverride
- path → String
-
The path component.
no setteroverride
-
pathSegments
→ List<
String> -
The URI path split into its segments.
no setteroverride
- port → int
-
The port part of the authority component.
no setteroverride
- query → String
-
The query component.
no setteroverride
-
queryParameters
→ Map<
String, String> -
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.
no setteroverride
-
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.
no setteroverride
- rawValue → String
-
Raw string value used by Uri.parse.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scheme → String
-
The scheme component of the URI.
no setteroverride
- uriValue → Uri
-
Uri parsed value. If isValidUri is
false
, the value will beUri()
.no setter - userInfo → String
-
The user info part of the authority component.
no setteroverride
Methods
-
isScheme(
String scheme) → bool -
Whether the scheme of this Uri is
scheme
.override -
normalizePath(
) → Uri -
Returns a URI where the path has been normalized.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
override
-
removeFragment(
) → Uri -
Creates a
Uri
that differs from this only in not having a fragment.override -
replace(
{String? scheme, String? userInfo, String? host, int? port, String? path, Iterable< String> ? pathSegments, String? query, Map<String, dynamic> ? queryParameters, String? fragment}) → Uri -
Creates a new
Uri
based on this one, but with some parts replaced.override -
resolve(
String reference) → Uri -
Resolve
reference
as an URI relative tothis
.override -
resolveUri(
Uri reference) → Uri -
Resolve
reference
as a URI relative tothis
.override -
toFilePath(
{bool? windows}) → String -
Creates a file path from a file URI.
override
-
toString(
) → String -
If forceToStringRawValue is
true
or isValidUri isfalse
, it returns rawValue, otherwise the value of uriValue.toString()
.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override