removeSpecialCharacters static method
Remove special characters from string
text - The text to process
keepSpaces - Whether to keep spaces (default: true)
Returns text without special characters
Implementation
static String removeSpecialCharacters(String text, {bool keepSpaces = true}) {
if (keepSpaces) {
return text.replaceAll(RegExp(r'[^a-zA-Z0-9\s]'), '');
} else {
return text.replaceAll(RegExp(r'[^a-zA-Z0-9]'), '');
}
}