isValidEmail function
Checks if string is email.
Implementation
bool isValidEmail(
String? inputString, {
bool isRequired = false,
}) {
bool isInputStringValid = false;
if (!isRequired && (inputString == null ? true : inputString.isEmpty)) {
isInputStringValid = true;
}
if (inputString != null && inputString.isNotEmpty) {
const pattern =
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
final regExp = RegExp(pattern);
isInputStringValid = regExp.hasMatch(inputString);
}
return isInputStringValid;
}