Thursday, May 13, 2021

Customize Error Widget App Flutter

Today is holiday Eid Mubarak in Indonesia. So Having much time to spend with family and hobby. And I want to say Eid Mubarak. And What I'm gonna share this today it's simple. It's related with ui widget error that we often face when something wrong with our ui widget. It could be like returning null inside BuildContext. Like screenshot above, I accidentally made the error but it could be real error next time lol.

So what the production build handle this kind of error ? It just show empty white screen. And this is what we want to customize it. It's better if we we show error message and one button to reset the app. So the user experience will be much better. 

Fortunetly the implementation is not hard to do. You just need to implement ErrorWidget.builder in main class with your error custom widget. As example below that I create. You can create your own class to customize the UI. Don't forget you need to pass one parameter to your class that's FlutterErrorDetails. 



The object will handle the error message then you can show it into ui screen. Therefore your screen will never be blank again in your production. And in development you can insert log to capture the error. That'll be benefit for your error tracking. Because there's possibility your screen will get this widget error.


Seems many flutter developer underestimate this powerful error. But if your app is already in production. You can feel the benefit using of this. If you find this useful, please subscribe and like. Haha this is not youtube. If you have any questions, please feel free to ask on the comment. Thanks for watching.

No comments:

Post a Comment