I'm trying to make a Login form in flutter using a string function here is the code:
String validateEmail(String value) {
String _msg;
RegExp regex = RegExp(
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,}))$');
if (value.isEmpty) {
_msg = "Your username is required";
} else if (!regex.hasMatch(value)) {
_msg = "Please provide a valid email address";
}
return _msg;
}
I get this error:
The non-nullable local variable '_msg' must be assigned before it can be used.