throw, try, and catch
Detect and respond to failures.
When Things Go Wrong
Programs hit problems: bad input, missing files, broken math. Dart signals these with an exception instead of silently misbehaving. 🚨
Throwing an Exception
You raise a problem yourself with throw. It stops normal flow right where it happens and hands control off to a handler.
throw Exception('Something failed');