Include "space" check in email adress flutter
5,514
Contains works perfectly for me.
void main() {
bool check;
String email = 'tes [email protected]';
check = email.contains(' ');
print(check); // true
}
I have tried it on DartPad
Perhaps you forgot to put whitespace between quotes.
Author by
sls
Updated on December 11, 2022Comments
-
sls over 1 year
Can someone please tell me how to add "space" check in email address? I have tried email.contains("") bt it didnt worked.
I don't get a error when i type invalid email
import 'dart:async'; class Validators{ final validEmail = StreamTransformer<String, String>.fromHandlers( handleData: (email, sink){ if(email.contains('@')){ sink.add(email); }else if(email.contains(" ")){ sink.addError('Enter a valid email'); }else{ sink.addError('Enter a valid email'); } } ); final validPassword = StreamTransformer<String, String>.fromHandlers( handleData: (password, sink){ if(password.length > 4){ sink.add(password); }else{ sink.addError('Enter a valid password'); } } ); }
-
Eugene almost 5 yearsCan you provide more details about the final result you are trying to achieve and maybe some code? You want to check if the user put only space or you want to detect space at any position in the entered line?
-
sls almost 5 yearsI want to check if user inserts space in email adress code should return with invalid email adress
-
-
sls almost 5 yearsThank- you for your answer. Can u please look at my code and give answer according to it.
-
Martyns almost 5 years@sls Updated answer
-
Randal Schwartz almost 5 yearsNo, see my answer.
-
Randal Schwartz almost 5 yearsNo, see my answer. Space is perfectly valid in an email address if quoted properly.