Dart handles errors and unexpected situations using exceptions. You catch exceptions to prevent your app from crashing when something goes wrong.
try
— code that might throw an exception.catch
— block to handle the exception.finally
— runs whether or not an exception occurs (for cleanup).throw
— manually trigger an exception.throw FormatException("Invalid format!");