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.