Dart Uri isAbsolute
Syntax & Examples
Uri.isAbsolute property
The `isAbsolute` property in Dart's Uri class returns whether the URI is absolute.
Syntax of Uri.isAbsolute
The syntax of Uri.isAbsolute property is:
bool isAbsolute
This isAbsolute property of Uri returns whether the URI is absolute.
Return Type
Uri.isAbsolute returns value of type bool
.
✐ Examples
1 Checking an absolute URI
In this example,
- We parse an absolute URI.
- We access the `isAbsolute` property of the URI.
- We print the result, which is true since the URI is absolute.
Dart Program
void main() {
Uri uri1 = Uri.parse('https://example.com');
print(uri1.isAbsolute); // true
}
Output
true
2 Checking a relative URI
In this example,
- We parse a relative URI.
- We access the `isAbsolute` property of the URI.
- We print the result, which is false since the URI is not absolute.
Dart Program
void main() {
Uri uri2 = Uri.parse('example.com');
print(uri2.isAbsolute); // false
}
Output
false
Summary
In this Dart tutorial, we learned about isAbsolute property of Uri: the syntax and few working examples with output and detailed explanation for each example.