diff --git a/lib/utils/error_reporter.dart b/lib/utils/error_reporter.dart index 93d32036..cd051abb 100644 --- a/lib/utils/error_reporter.dart +++ b/lib/utils/error_reporter.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_highlighter/flutter_highlighter.dart'; @@ -20,6 +21,7 @@ class ErrorReporter { void onErrorCallback(Object error, [StackTrace? stackTrace]) async { Logs().e(message ?? 'Error caught', error, stackTrace); + final text = '$error\n${stackTrace ?? ''}'; final consent = await showAdaptiveDialog( context: context, builder: (context) => AlertDialog.adaptive( @@ -29,7 +31,7 @@ class ErrorReporter { width: 256, child: SingleChildScrollView( child: HighlightView( - '$error\n${stackTrace ?? ''}', + text, language: 'sh', theme: shadesOfPurpleTheme, ), @@ -40,6 +42,12 @@ class ErrorReporter { onPressed: () => Navigator.of(context).pop(false), child: Text(L10n.of(context)!.close), ), + TextButton( + onPressed: () => Clipboard.setData( + ClipboardData(text: text), + ), + child: Text(L10n.of(context)!.copy), + ), TextButton( onPressed: () => Navigator.of(context).pop(true), child: Text(L10n.of(context)!.report), @@ -58,7 +66,7 @@ class ErrorReporter { $error ### StackTrace -$stackTrace +${stackTrace?.toString().split('\n').take(10).join('\n')} '''; launchUrl( AppConfig.newIssueUrl.resolveUri(