fix: URL too long when reporting bug

This commit is contained in:
Krille 2024-01-06 12:58:39 +01:00
parent d8414e8d15
commit faf4ecd088
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652

View file

@ -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<bool>(
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<bool>(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<bool>(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(