verifyLength function

bool verifyLength(
  1. List list,
  2. int length, [
  3. String? message
])

Verify that a list has a specific length.

Example:

verifyLength(items, 3, 'Should have exactly 3 items');

Returns true if the verification passed, false otherwise.

Implementation

bool verifyLength(List list, int length, [String? message]) {
  if (list.length != length) {
    final msg = message ?? 'Expected length $length but got ${list.length}';
    _verificationFailures.add(msg);
    return false;
  }
  return true;
}