compareTo method

  1. @override
int compareTo(
  1. ChildKey other
)
override

Compares this object to another object.

Returns a value like a Comparator when comparing this to other. That is, it returns a negative integer if this is ordered before other, a positive integer if this is ordered after other, and zero if this and other are ordered together.

The other argument must be a value that is comparable to this object.

Implementation

@override
int compareTo(ChildKey other) {
  if (identical(this, other)) {
    return 0;
  } else if (identical(this, min) || identical(other, max)) {
    return -1;
  } else if (identical(other, min) || identical(this, max)) {
    return 1;
  }
  final int? a = intValue;
  final int? b = other.intValue;
  if (a != null) {
    if (b == null) {
      return -1;
    }
    final int diff = a - b;
    return diff == 0 ? name.length - other.name.length : diff;
  } else if (b != null) {
    return 1;
  }
  return name.compareTo(other.name);
}