颤振|如何检查字符串是否不包含子字符串或字符



我正在学习Flutter/Dart,并且我想执行此检查-验证已输入电子邮件的用户应在其中包含@

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')

有没有人建议有任何内置的函数来做这样的事情?

只需将非!操作符(也称为零安全bang操作符)放在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');
}

相关内容