Assertion with assert
Learn how to use the assert statements in Dart.
We'll cover the following...
assert
is an incredibly useful statement that allows you to put conditions on code execution. It’s used to disrupt normal execution when a boolean condition is false
.
Syntax
The syntax is as follows:
Press + to interact
assert(condition, optional message)
The first argument passed to assert
can be any expression that reduces to a boolean value. If the expression’s value is ...