hasText static method

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

Asserts that the given text contains non-whitespace characters.

Throws an InvalidArgumentException with the given message if the text is null, empty, or contains only whitespace.

Example:

Assert.hasText(comment, 'Comment cannot be blank');

Implementation

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