isLatin method Null safety

bool? isLatin()

Checks if the String has only Latin characters.

Example

String foo = 'this is a τεστ';
bool isLatin = foo.isLatin(); // returns false
String foo2 = 'this is hello world';
bool isLatin2 = foo2.isLatin(); // returns true

Implementation

bool? isLatin() {
  if (this == null) {
    return null;
  }
  if (this!.isEmpty) {
    return null;
  }
  return RegExp(r'^[a-zA-Z\s]+$').hasMatch(this!);
}