isTrue static method

void isTrue(
  1. bool expression,
  2. String message
)

Asserts that a boolean expression is true.

Throws an InvalidArgumentException with the given message if the expression evaluates to false.

Example:

Assert.isTrue(age > 18, 'Age must be greater than 18');

Implementation

static void isTrue(bool expression, String message) {
  if (!expression) {
    throw InvalidArgumentException(message);
  }
}