Assert class
Annotation util for performing build time asserts in the global namespace. This is useful for validating compile-time constants in a way that fails early, before runtime.
For example:
@Assert(
myBuildTimeVal == 'val_a' || myBuildTimeVal == 'val_b',
'myBuildTimeVal must be one of "val_a" or "val_b"',
)
const myBuildTimeVal = String.fromEnvironment('MY_VAL');
// Running this with '--define=MY_VAL=foo' will fail compilation.
void main() {
print('myBuildTimeVal is $myBuildTimeVal');
}
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