isAscii static method

bool isAscii(
  1. String s
)

Checks if the given string s contains only ascii chars

Implementation

static bool isAscii(String s) {
  try {
    asciiCodec.decode(s.codeUnits);
  } catch (e) {
    return false;
  }
  return true;
}