containsIgnoreCase method
Returns true if this string contains other in a case-insensitive
manner.
An empty string is considered to be contained in any string. Returns
false only when other is null.
Example:
'Hello World'.containsIgnoreCase('world'); // true
'Hello World'.containsIgnoreCase('HELLO'); // true
'Hello World'.containsIgnoreCase(null); // false
Implementation
@useResult
bool containsIgnoreCase(String? other) {
if (other == null) {
return false;
}
if (other.isEmpty) {
return true;
}
return toLowerCase().contains(other.toLowerCase());
}