Add clear button to logs
This commit is contained in:
parent
a2e70f7dff
commit
b3718932e1
@ -458,32 +458,54 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final actionButtonLogs = FloatingActionButton(
|
final actionButtonLogs = Row(
|
||||||
onPressed: () {
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
// Copy the logs to the clipboard
|
children: [
|
||||||
final error = widget.errorNotifier.value;
|
Padding(
|
||||||
if (error != null) {
|
padding: EdgeInsets.only(right: 30),
|
||||||
SystemChannels.platform.invokeMethod<void>(
|
child: FloatingActionButton(
|
||||||
'Clipboard.setData',
|
onPressed: () {
|
||||||
<String, dynamic>{'text': error},
|
// Clear the logs
|
||||||
);
|
widget.errorNotifier.value = null;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text("Logs copied to clipboard."),
|
content: Text("Logs cleared."),
|
||||||
duration: const Duration(seconds: 3),
|
duration: const Duration(seconds: 3),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
},
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
tooltip: 'Clear Logs',
|
||||||
SnackBar(
|
child: const Icon(Icons.delete),
|
||||||
content: Text("No logs to copy."),
|
),
|
||||||
duration: const Duration(seconds: 3),
|
),
|
||||||
),
|
FloatingActionButton(
|
||||||
);
|
onPressed: () {
|
||||||
}
|
// Copy the logs to the clipboard
|
||||||
},
|
final error = widget.errorNotifier.value;
|
||||||
tooltip: 'Copy Logs',
|
if (error != null) {
|
||||||
child: const Icon(Icons.copy),
|
SystemChannels.platform.invokeMethod<void>(
|
||||||
|
'Clipboard.setData',
|
||||||
|
<String, dynamic>{'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(
|
final actionButtonInfo = FloatingActionButton(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user