equals method

bool equals(
  1. Object? other, {
  2. bool ignoreCase = true,
})

Check equals with optional case-insensitive check

Implementation

bool equals(Object? other, {bool ignoreCase = true}) {
  final a = this;
  final b = other;

  if (a == null && b == null) return true;
  if (a == null || b == null) return false;

  if (a is String && b is String && ignoreCase) {
    return a.trim().toLowerCase() == b.trim().toLowerCase();
  }

  return a == b;
}