isMail property

bool? isMail

Checks whether the String is a valid mail.

Example

String foo = 'esentis@esentis.com';
bool isMail = foo.isMail; // returns true

Implementation

bool? get isMail {
  if (this == null) return null;
  if (this!.isEmpty) return false;
  final regex = RegExp(r"(^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$)");
  return regex.hasMatch(this!);
}