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,

  1. We parse an absolute URI.
  2. We access the `isAbsolute` property of the URI.
  3. 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,

  1. We parse a relative URI.
  2. We access the `isAbsolute` property of the URI.
  3. 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.