hasLength static method

void hasLength(
  1. String? text,
  2. String message
)

Asserts that the given text is not null and not empty.

Throws an InvalidArgumentException with the given message if the text is null or empty.

Example:

Assert.hasLength(password, 'Password cannot be empty');

Implementation

static void hasLength(String? text, String message) {
  if (text == null || text.isEmpty) {
    throw InvalidArgumentException(message);
  }
}