swapCase method

String? swapCase()

Change given text case For example change lower case to upper and upper to lower ('HeLlo worLd' => 'hElLO WORlD')

Implementation

String? swapCase() {
  if (this == null) {
    return null;
  }

  return this!.split('').map((String e) {
    if (e.toLowerCase() == e) {
      return e.toUpperCase();
    } else {
      return e.toLowerCase();
    }
  }).join('');
}