An Error Handler for Flutter

Greg Perry
Flutter Community
Published in
9 min readFeb 10, 2020

--

A way to implement error handling in your Flutter app.

Let’s take a closer look at the ‘Error Handler’ first introduced at the end of a previous article, Error Handling in Flutter. Note, it’s suggested you read this previous article first to get up to speed. This class allows you to introduce your own error-handler to either your app as a whole or to only segments of your code. Admittedly, such an ability may only be useful to a larger app involving multiple developers, but it’s hoped the class will at least give you some ideas on the subject of Error Handling.

In this quick little article, we will walk through parts of the class explaining the role they play in providing error handling. You will be presented with some sample code to demonstrate how the class is implemented. Of course, the class, ErrorHandler, is available to you on Github. Take it and make it your own. Error handling is a necessity in every app. If anything, maybe this article will get you to start thinking about handling errors. Do it! Handle your errors. They will occur!

Let’s Begin.

Other Stories by Greg Perry

At the beginning of the class, ErrorHandler, you can see both the original ‘error handler’ and ‘ErrorWidget’ routines that are currently called when an error occurs are recorded in package-private variables in the class’ constructor. As a reminder, the ‘ErrorWidget’ is…

--

--