Failed assertion: boolean expression must not be null出现这种情况是你的 if中的条件或者其他条件为null,如下两种条件,
原因貌似是在dart中bool的值只有 true 或者 false,所以 null不会被视为false ,同理 >1的数也不会视为true,反而会出现错误。
这大概和dart什么都是对象属性有关,bool值true fasle 也是对象,其他对象自然不能填入
dart官网原话:To represent boolean values, Dart has a type named bool. Only two objects have type bool: the boolean literals true and false, which are both compile-time constants.
if(条件)
条件?doOne():doTwo()
————————————————
版权声明:本文为CSDN博主「ASH救世主」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_32319999/article/details/80667336