non_bool_operand
The operands of the operator '{0}' must be assignable to 'bool'.
Description
#The analyzer produces this diagnostic when one of the operands of either
the &&
or ||
operator doesn't have the type bool
.
Example
#The following code produces this diagnostic because a
isn't a Boolean
value:
dart
int a = 3;
bool b = a || a > 1;
Common fixes
#Change the operand to a Boolean value:
dart
int a = 3;
bool b = a == 0 || a > 1;
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。