toggleCase method

String toggleCase()

Toggles the case of each character in the string.

Implementation

String toggleCase() => split('').map((char) {
      if (char == char.toUpperCase()) {
        return char.toLowerCase();
      } else {
        return char.toUpperCase();
      }
    }).join();