Disable Flutter's "red screen of death" Disable Flutter's "red screen of death" flutter flutter

Disable Flutter's "red screen of death"


You could override ErrorWidget.builder method.
I'm resolved this.

・Example code.

void main() {    ErrorWidget.builder = (FlutterErrorDetails details) => Container();    ...}

・Default code

static ErrorWidgetBuilder builder = _defaultErrorWidgetBuilder;

I hoped its your help.


2019 12 21 updated

Or Change ErrorWidget backgroundColor and textStyle.

・Example code

import 'dart:ui' as ui;void main() {    RenderErrorBox.backgroundColor = Colors.transparent;    RenderErrorBox.textStyle = ui.TextStyle(color: Colors.transparent);}


You can try to use Catcher which is a free flutter plugin which catches and handles errors in Flutter application. Catcher offers multiple report modes and handlers to cooperate with Flutter applications

just add catcher in your pubspec.yaml

catcher: ^0.1.2

For more info about catcher https://pub.dartlang.org/packages/catcher

A nice tutorial to get started with catcher https://medium.com/flutter-community/handling-flutter-errors-with-catcher-efce74397862


void main() { bool isDev = true;          ErrorWidget.builder = (FlutterErrorDetails errorDetails) {            return AppErrorWidget(              errorDetails: errorDetails,              isDev: isDev,            );          };}              class AppErrorWidget extends StatelessWidget {      final FlutterErrorDetails errorDetails;      final bool isDev;      const AppErrorWidget({        Key key,        @required this.errorDetails,        this.isDev = false,      }) : super(key: key);      @override      Widget build(BuildContext context) {        return Material(          child: SafeArea(            child: Container(              decoration: BoxDecoration(border: Border.all(color: Colors.red)),              child: ListView(                children: <Widget>[                  Container(                    height: 20,                  ),                  Text(isDev ? errorDetails.toString() : '')                ],              ),            ),          ),        );      }    }