hasSameCharacters property

bool hasSameCharacters

Checks if the String is consisted of same characters (ignores cases).

Example

String foo1 = 'ttttttt'
bool hasSame1 = foo.hasSameCharacters(); // true;
String foo = 'ttttttt12'
bool hasSame2 = foo.hasSameCharacters();  // false;

Implementation

bool get hasSameCharacters {
  if (this.isBlank) {
    return false;
  }

  if (this.length > 1) {
    var b = this[0].toLowerCase();
    for (var i = 1; i < this.length; i++) {
      var c = this[i].toLowerCase();
      if (c != b) {
        return false;
      }
    }
  }
  return true;
}