File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,15 @@ Future<void> initDisplayMode() async {
168168Future <void > onError (FlutterErrorDetails details) async {
169169 File errorFile = File (join (await FileUtil .getLogDir (), "error.log" ));
170170 if (! errorFile.existsSync ()) errorFile.createSync ();
171- errorFile.writeAsStringSync (details.toString (), mode: FileMode .append);
171+ final currentTime = DateTime .now ().toIso8601String ();
172+ final errorDetails = [
173+ 'Time: $currentTime ' ,
174+ 'Exception: ${details .exception }' ,
175+ 'Stack trace:\n ${details .stack ?? 'No stack trace available' }' ,
176+ 'Library: ${details .library ?? 'Unknown library' }' ,
177+ 'Context: ${details .context ?.toDescription () ?? 'No context available' }' ,
178+ ].join ('\n ' );
179+ errorFile.writeAsStringSync ('$errorDetails \n\n ' , mode: FileMode .append);
172180 if (details.stack != null ) {
173181 Zone .current.handleUncaughtError (details.exception, details.stack! );
174182 }
You can’t perform that action at this time.
0 commit comments