Booleans

To represent boolean values, Dart has a type named bool. Only twoobjects have type bool: the boolean literals true and false,which are both compile-time constants.

Dart’s type safety means that you can’t use code likeif (nonbooleanValue) orassert (nonbooleanValue).Instead, explicitly check for values, like this:

1. // Check for an empty string.
2. var fullName = '';
3. assert(fullName.isEmpty);

5. // Check for zero.
6. var hitPoints = 0;
7. assert(hitPoints <= 0);

9. // Check for null.
10. var unicorn;
11. assert(unicorn == null);

13. // Check for NaN.
14. var iMeantToDoThis = 0 / 0;
15. assert(iMeantToDoThis.isNaN);