isLowerCase function

bool isLowerCase(
  1. String s,
  2. bool ignoreSymbols
)

Check if characters of a String are lowercase.

Implementation

bool isLowerCase(String s, bool ignoreSymbols) {
  if (ignoreSymbols) {
    return s.toLowerCase() == s;
  } else {
    if (s.isEmpty) {
      return false;
    }
    for (int i = 0; i < s.length; i++) {
      String current = s.substring(i, i + 1);
      //return false for symbols
      if (current.toUpperCase() == current.toLowerCase()) {
        return false;
      } else if (current != current.toLowerCase()) {
        return false;
      }
    }

    return true;
  }
}