isAscii property
Checks whether the String
is a valid ASCII string.
Example
String foo = 'Hello World';
bool isAscii = foo.isAscii; // returns true;
String foo = 'œ∑´®†¥¨ˆøπ';
bool isAscii = foo.isAscii; // returns false;
Implementation
bool get isAscii {
if (isEmpty) {
return true;
}
final ascii = RegExp(r'^[\x00-\x7F]+$');
return ascii.hasMatch(this);
}