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

Flutter | How to check if String does not contain a substring or a character

我正在学习 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')

有人可以建议是否有任何内置函数可以做这样的事情。

只需将 not ! 运算符(也称为 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');
}