containsDiacritics method
Accurately checks if the string contains any diacritical characters that can be removed by the removeDiacritics method.
Returns true
if a known diacritic character is found, false
otherwise.
Implementation
bool containsDiacritics() {
// An empty string cannot contain diacritics.
if (isEmpty) {
return false;
}
// Check if any character in the string exists as a key in our map of diacritics.
// This is more accurate than the previous regex approach.
return split('').any((String char) => _reverseAccentsMap.containsKey(char));
}