Skip to content

Files

Latest commit

 

History

History
34 lines (25 loc) · 704 Bytes

prefer_bool_in_asserts.md

File metadata and controls

34 lines (25 loc) · 704 Bytes

Pattern: Missing use of boolean in assert

Issue: -

Description

Not using booleans in assert conditions can lead to code where it isn't clear what the intention of the assert statement is.

Example of incorrect code:

assert(() {
 f();
 return true;
});

Example of correct code:

assert(() {
 f();
 return true;
}());

DEPRECATED: In Dart 2, asserts no longer accept non-bool values so this rule is made redundant by the Dart analyzer's basic checks and is no longer necessary.

The rule will be removed in a future Linter release.

Further Reading