Dart List hashCode
Syntax & Examples
Syntax of List.hashCode
The syntax of List.hashCode property is:
int hashCode This hashCode property of List the hash code for this object.
Return Type
List.hashCode returns value of type int.
✐ Examples
1 Get hash code of a string
In this example,
- We create a string
'Hello'. - We then use the
hashCodeproperty to get its hash code. - We print the hash code to standard output.
Dart Program
void main() {
int hashCodeValue = 'Hello'.hashCode;
print(hashCodeValue);
}Output
180399535
2 Get hash code of an integer
In this example,
- We create an integer
123. - We then use the
hashCodeproperty to get its hash code. - We print the hash code to standard output.
Dart Program
void main() {
int hashCodeValue = 123.hashCode;
print(hashCodeValue);
}Output
123
3 Get hash code of a boolean
In this example,
- We create a boolean
true. - We then use the
hashCodeproperty to get its hash code. - We print the hash code to standard output.
Dart Program
void main() {
int hashCodeValue = true.hashCode;
print(hashCodeValue);
}Output
519018
Summary
In this Dart tutorial, we learned about hashCode property of List: the syntax and few working examples with output and detailed explanation for each example.