hasSameCharacters property

bool get 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 (isBlank) {
    return false;
  }

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