Create a custom error screen

Flutter tips Published on

Bored of seeing the default red or grey screen when something goes wrong in your Flutter app?

What's the Default?

Flutter shows a red screen (debug mode) or a grey screen (production mode) by default when there's a rendering error.

Override the Default

You can change this behavior.

Stop Showing the Default Screen

To stop Flutter from showing the default red/grey screen, you can remove the presentError function call in FlutterError.onError.

Using ErrorWidget.builder

A common way is to override the default error widget using ErrorWidget.builder in your MaterialApp. This lets you show your own widget instead of the default error screen.

You can create a simple text message or a more complex UI. The code from the image shows how to make a basic text widget display the error summary.

Other Options

Instead of just showing an error widget, you could also:

This gives users a better experience when errors happen.

Save 3 months of work

Create your app using our 6 years of making Flutter apps and more than 50+ apps

kickstarter for flutter apps

Frequently Asked Questions

What is the default error screen in Flutter?

In debug mode, it's a red screen. In production mode, it's usually a grey screen.

How can I stop Flutter from showing the default error screen?

You can remove the `FlutterError.presentError(details);` line within the `FlutterError.onError` callback.

How can I show my own custom error screen?

You can use `ErrorWidget.builder` within your `MaterialApp` widget to provide your own widget to display when an error occurs.

Can I do something else instead of showing a custom error widget?

Yes, you could redirect the user to another page or show a temporary message like a toast notification.

Read more
You may also be interested in
Circular avatar with border  blog card image
Circular avatar with border
Published on 2025-05-13T07:06:03.470Z
Check for outdated dependencies  blog card image
Check for outdated dependencies
Published on 2025-05-13T07:04:17.886Z
ApparenceKit is a flutter template generator tool by Apparence.io © 2025.
All rights reserved