I'm learning Flutter/Dart and there is this check that i want to perform - to validate that a user who has entered an email should contain @ in it
String myString = 'Dart';
// just like i can do the following check
myString.contains('a') ? print('validate') : print('does not validate')
// I want to do another check here
myString does not contain('@') ? print('does not validate'): print('validate')
Can someone suggest is there any inbuilt function to do such a thing.
CodePudding user response:
Just simply put not !
operator (also known as bang
operator on null-safety) on start
void main() {
String myString = 'Dart';
// just like i can do the following check
myString.contains('a') ? print('validate') : print('does not validate');
// I want to do another check here
!myString.contains('@') ? print('does not validate') : print('validate');
}