post method
Checks a postcondition on this value and returns it.
Postconditions verify that a result satisfies expected conditions. The condition function receives this value and should return true if the postcondition is satisfied.
The assertion runs in a finally block, ensuring it executes before the value is returned to the caller.
Parameters:
condition: Predicate function that verifies the postconditionmessage: Error message if the postcondition fails
Returns: This value (allowing for method chaining)
Example:
final result = compute()
.post((r) => r >= 0, 'Result must be non-negative');
Implementation
T post(bool Function(T) condition, String message) {
assert(condition(this), '🔴 Postcondition: $message');
return this;
}