Skip to content

Commit fca80a6

Browse files
committed
Re-enable flutter general error handling, but only in release mode
1 parent 62853bc commit fca80a6

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

lib/main.dart

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,25 @@ void main() async {
9191
await PreferenceHelper.instance.migrationSupportFunctionForSharedPreferences();
9292

9393
// Catch errors from Flutter itself (widget build, layout, paint, etc.)
94-
// FlutterError.onError = (FlutterErrorDetails details) {
95-
// final stack = details.stack ?? StackTrace.empty;
96-
// if (kDebugMode) {
97-
// FlutterError.dumpErrorToConsole(details);
98-
// }
9994
//
100-
// // Don't show the full error dialog for network image loading errors.
101-
// if (details.exception is NetworkImageLoadException) {
102-
// return;
103-
// }
104-
//
105-
// // showGeneralErrorDialog(details.exception, stack);
106-
// // throw details.exception;
107-
// };
95+
// NOTE: it seems this sometimes makes problems and even freezes the flutter
96+
// process when widgets overflow, so it is disabled in dev mode.
97+
if (kReleaseMode) {
98+
FlutterError.onError = (FlutterErrorDetails details) {
99+
final stack = details.stack ?? StackTrace.empty;
100+
// if (kDebugMode) {
101+
// FlutterError.dumpErrorToConsole(details);
102+
// }
103+
104+
// Don't show the full error dialog for network image loading errors.
105+
if (details.exception is NetworkImageLoadException) {
106+
return;
107+
}
108+
109+
showGeneralErrorDialog(details.exception, stack);
110+
// throw details.exception;
111+
};
112+
}
108113

109114
// Catch errors that happen outside of the Flutter framework (e.g., in async operations)
110115
PlatformDispatcher.instance.onError = (error, stack) {

0 commit comments

Comments
 (0)