Assert class

A utility class that provides static assertion methods for validating arguments and states in your application.

These methods help ensure that certain conditions hold true at runtime. If a condition fails, an appropriate exception is thrown.

Example usage:

Assert.notNull(user, 'User must not be null');
Assert.hasText(username, 'Username must not be empty');
Assert.isInstanceOf<String>(input, 'Expected a String input');

Typically used in service classes, configuration validation, or during framework lifecycle operations.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

doesNotContain(String? textToSearch, String substring, String message) → void
Asserts that the given textToSearch does not contain the given substring.
hasLength(String? text, String message) → void
Asserts that the given text is not null and not empty.
hasText(String? text, String message) → void
Asserts that the given text contains non-whitespace characters.
isInstanceOf<T>(Object? obj, String message) → void
Asserts that the given obj is an instance of type T.
isTrue(bool expression, String message) → void
Asserts that a boolean expression is true.
notEmpty(List? list, String message) → void
Asserts that the given list is not null and not empty.
notEmptyMap(Map? map, String message) → void
Asserts that the given map is not null and not empty.
state(bool expression, String message) → void
Asserts that a boolean expression is true.