configureErrorWidgetBuilder function
void
configureErrorWidgetBuilder({
- required bool isProduction,
- ErrorWidgetBuilder? productionBuilder,
Show error unless ReleaseMode and isProduction is true.
Modified from this: https://github.com/flutter/flutter/blob/62621507966463f9fe678b3e249a64f1be11c9a1/packages/flutter/lib/src/widgets/framework.dart#L4376
Implementation
void configureErrorWidgetBuilder({
required bool isProduction,
ErrorWidgetBuilder? productionBuilder,
}) {
ErrorWidget.builder = (details) {
final message = kReleaseMode && isProduction
? ''
: '${_stringifyException(details.exception)}\n'
'See also: https://flutter.dev/docs/testing/errors';
final dynamic exception = details.exception;
if (isProduction && productionBuilder != null) {
return productionBuilder(details);
}
return ErrorWidget.withDetails(
message: message,
error: exception is FlutterError ? exception : null,
);
};
}