Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created April 7, 2025 14:22
Show Gist options
  • Save fredgrott/d0bd099f6a4ace8fa20cf06fc5e3658f to your computer and use it in GitHub Desktop.
Save fredgrott/d0bd099f6a4ace8fa20cf06fc5e3658f to your computer and use it in GitHub Desktop.
student value class example
class Student implements Comparable<Student> {
final String name;
const Student(this.name);
String toString() => "Student: $name";
bool operator ==(Object other) =>
identical(this, other) ||
other is Student &&
runtimeType == other.runtimeType &&
name == other.name;
int get hashCode => name.hashCode;
int compareTo(Student other) => name.compareTo(other.name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment