Dart中惯用的“不是”

cre*_*not 4 dart

没有比“ 不是 ” 更具体的表达方式!(o is T)

/// Object (o) is not type (T)
/// 
/// Syntax that works but is not concise: `!(o is T)`

final word = 'drow';

if (!(word is String)) print('undoable');
Run Code Online (Sandbox Code Playgroud)

Ale*_*uin 5

您可以使用o is! T

if (word is! String) print('undoable');
Run Code Online (Sandbox Code Playgroud)

请参阅类型测试运算符