From the course: Flutter Essential Training: Build for Multiple Platforms

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Exception handling

Exception handling

- [Instructor] When the application is behaving unexpectedly or it's unable to complete its operation because of an undefined result or behavior, it must have thrown an exception. Imagine dividing a number by a string, that operation will not complete and will eventually throw an exception. When an application throws an exception, the developer has to handle that scenario and maybe show a fancy UI or a nice message to the user, letting them know something went wrong, so users can still have a good user experience. This is called exception handing. Only when you were writing the method to fetch the network images here, we wrote a logic to check if the response status code is 200, then we convert this to our Dart model class. Otherwise we throw a custom exception. So note what I said, it is a custom exception. That means there must be some non-custom exceptions that are thrown by Flutter itself, so, by the SDK, and we…

Contents