Dart Uri hashCode
Syntax & Examples


Uri.hashCode property

The `hashCode` property in Dart's Uri class returns a hash code computed as `toString().hashCode`.


Syntax of Uri.hashCode

The syntax of Uri.hashCode property is:

 int hashCode 

This hashCode property of Uri returns a hash code computed as toString().hashCode.

Return Type

Uri.hashCode returns value of type int.



✐ Example

1 Getting the hash code for a URI

In this example,

  1. We parse two different URIs.
  2. We access the `hashCode` property of each URI.
  3. We print the hash codes to standard output.

Dart Program

void main() {
  Uri uri1 = Uri.parse('https://example.com/page1');
  Uri uri2 = Uri.parse('https://example.com/page2');
  print(uri1.hashCode); // hash code for uri1
  print(uri2.hashCode); // hash code for uri2
}

Output

86864378
397727497

Summary

In this Dart tutorial, we learned about hashCode property of Uri: the syntax and few working examples with output and detailed explanation for each example.