From b3718932e16fc16506d5be6edbccf89078781de9 Mon Sep 17 00:00:00 2001 From: lemoer Date: Sat, 19 Jul 2025 12:50:19 +0200 Subject: [PATCH] Add clear button to logs --- lib/main.dart | 74 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 7839fbc..2082ca4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -458,32 +458,54 @@ class _MyHomePageState extends State { ), ); - final actionButtonLogs = FloatingActionButton( - onPressed: () { - // Copy the logs to the clipboard - final error = widget.errorNotifier.value; - if (error != null) { - SystemChannels.platform.invokeMethod( - 'Clipboard.setData', - {'text': error}, - ); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Logs copied to clipboard."), - duration: const Duration(seconds: 3), - ), - ); - } else { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("No logs to copy."), - duration: const Duration(seconds: 3), - ), - ); - } - }, - tooltip: 'Copy Logs', - child: const Icon(Icons.copy), + final actionButtonLogs = Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: EdgeInsets.only(right: 30), + child: FloatingActionButton( + onPressed: () { + // Clear the logs + widget.errorNotifier.value = null; + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Logs cleared."), + duration: const Duration(seconds: 3), + ), + ); + }, + tooltip: 'Clear Logs', + child: const Icon(Icons.delete), + ), + ), + FloatingActionButton( + onPressed: () { + // Copy the logs to the clipboard + final error = widget.errorNotifier.value; + if (error != null) { + SystemChannels.platform.invokeMethod( + 'Clipboard.setData', + {'text': error}, + ); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Logs copied to clipboard."), + duration: const Duration(seconds: 3), + ), + ); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("No logs to copy."), + duration: const Duration(seconds: 3), + ), + ); + } + }, + tooltip: 'Copy Logs', + child: const Icon(Icons.copy), + ), + ], ); final actionButtonInfo = FloatingActionButton(