isPalindrome method

bool isPalindrome()

Check if a string reads the same forward and backward.

Implementation

bool isPalindrome() {
  String cleaned = toLowerCase().replaceAll(RegExp(r'\s+'), '');
  return cleaned == cleaned.split('').reversed.join('');
}