Debug Screen: Add a button to copy messages to the clipboard

This commit is contained in:
Vishesh Handa
2020-11-07 15:12:03 +01:00
parent 1ab2f8725e
commit 245ec8a53b
2 changed files with 18 additions and 0 deletions

View File

@ -10,6 +10,7 @@
image: ios_shortcuts.png
- text: "Custom SSH keys with passwords can now be used - #227"
- text: "Create new note when clicking on non existing Wiki Link - #240"
- text: "Debug Screen: Add a button to easily copy all the logs"
bugs:
- text: "Fix notes not always showing up - #270"

View File

@ -1,4 +1,7 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:provider/provider.dart';
@ -52,6 +55,10 @@ class _DebugScreenState extends State<DebugScreen> {
},
),
actions: <Widget>[
IconButton(
icon: const Icon(Icons.copy),
onPressed: _copyToClipboard,
),
IconButton(
icon: const Icon(Icons.filter_list),
onPressed: _showFilterSelection,
@ -123,6 +130,16 @@ class _DebugScreenState extends State<DebugScreen> {
}
}
void _copyToClipboard() async {
var messages = <String>[];
for (var logMsg in _logs) {
var msg = json.encode(logMsg.toMap());
messages.add(msg);
}
Clipboard.setData(ClipboardData(text: messages.join('\n')));
}
Widget _buildLogWidget(LogMessage msg) {
var textStyle = Theme.of(context)
.textTheme