Provides checks for object invariants, preconditions, and postconditions.
In ContractCheckingMode.assertionsOnly, failed checks use Dart assertions. In ContractCheckingMode.alwaysThrow, failed checks throw a ContractViolationError.
Constructors
Properties
- contractCheckingMode → ContractCheckingMode
-
The mode used when evaluating this object's contracts.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
invariant(
) → bool - Returns whether this object is in a valid state.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
post(
{required bool condition(), required String message()}) → void - Checks a postcondition.
-
pre(
{required bool condition(), required String message()}) → void - Checks a precondition.
-
runWithInvariant<
R> (String description, R body()) → R -
Runs
bodyand evaluates invariant afterward, even ifbodythrows. -
runWithInvariantAsync<
R> (String description, Future< R> body()) → Future<R> -
Runs
bodyand evaluates invariant afterward, even ifbodythrows. -
toString(
) → String -
A string representation of this object.
inherited
-
verifyInvariant(
String description) → void - Checks whether this object's invariant currently holds.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited