nullLast<T extends Object> function

Comparator<T?> nullLast<T extends Object>(
  1. Comparator<T> comparator
)

Implementation

Comparator<T?> nullLast<T extends Object>(Comparator<T> comparator) {
  return (a, b) {
    return switch ((a, b)) {
      // see: https://github.com/dart-lang/sdk/issues/53033
      // ignore: constant_pattern_never_matches_value_type
      (null, null) => 0,
      // ignore: constant_pattern_never_matches_value_type
      (_, null) => -1,
      // ignore: constant_pattern_never_matches_value_type
      (null, _) => 1,
      _ => comparator(a!, b!),
    };
  };
}