isEquals method
Compares this string to other
, with options for case-insensitivity
and apostrophe normalization.
Implementation
bool isEquals(String? other, {bool ignoreCase = true, bool normalizeApostrophe = true}) {
// If other string is null, they can't be equal.
if (other == null) return false;
// Create mutable copies for normalization.
String first = this;
String second = other;
// If ignoring case, convert both to lowercase.
if (ignoreCase) {
first = first.toLowerCase();
second = second.toLowerCase();
}
// If normalizing apostrophes, replace variants with a standard one.
if (normalizeApostrophe) {
first = first.replaceAll(RegExp("['’]"), "'");
second = second.replaceAll(RegExp("['’]"), "'");
}
// Perform the final comparison.
return first == second;
}