isPalindrome static method
Checks if the String is a palindrome and returns a bool value.
Example:
String str = "hello world";
bool isPalindrome = StringUtils.isPalindrome(str);
print(isPalidrome); // false
Implementation
static bool isPalindrome(String text) {
String cleaned = text.replaceAll(RegExp(r'\s+'), '').toLowerCase();
return cleaned == cleaned.split('').reversed.join('');
}