equals method

bool equals(
  1. String other, {
  2. bool caseSensitive = true,
  3. Pattern? pattern,
  4. bool useThisInstead = false,
})

Equals is a similar function that use Java or Kotlin classes to see the equality from two objects

Implementation

bool equals(
  String other, {
  bool caseSensitive = true,
  Pattern? pattern,
  bool useThisInstead = false,
}) {
  if (!caseSensitive) return toLowerCase() == other.toLowerCase();
  return pattern != null
      ? pattern is RegExp
          ? pattern.hasMatch(useThisInstead ? this : other)
          : pattern.allMatches(useThisInstead ? this : other).isNotEmpty
      : this == other;
}