isEquals method

  1. @useResult
bool isEquals(
  1. String? other, {
  2. bool ignoreCase = true,
  3. bool normalizeApostrophe = true,
})

Returns true if this string equals other, with options for case-insensitivity via ignoreCase and apostrophe normalization via normalizeApostrophe.

Implementation

@useResult
bool isEquals(
  String? other, {
  bool ignoreCase = true,
  bool normalizeApostrophe = true,
}) {
  if (other == null) {
    return false;
  }

  String first = this;
  String second = other;

  if (ignoreCase) {
    first = first.toLowerCase();
    second = second.toLowerCase();
  }

  if (normalizeApostrophe) {
    first = first.replaceAll(_apostropheRegex, "'");
    second = second.replaceAll(_apostropheRegex, "'");
  }

  return first == second;
}