Throw
Here’s an example of throwing, or raising, an exception:
throw FormatException('Expected at least 1 section');
You can also throw arbitrary objects:
throw 'Out of llamas!';
Note: Production-quality code usually throws types that implement Error or Exception.
Because throwing an exception is an expression, you can throw exceptionsin => statements, as well as anywhere else that allows expressions:
void distanceTo(Point other) => throw UnimplementedError();