Add copy buttons to JSON-Debug view
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pretty_json/pretty_json.dart';
|
||||
|
||||
class JsonViewer extends StatelessWidget {
|
||||
@ -29,10 +30,20 @@ class JsonViewer extends StatelessWidget {
|
||||
showDialog(context: context, builder: (context) {
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
title: const Text("Rohdaten"),
|
||||
title: Row(children: const [Icon(Icons.bug_report_outlined), Text("Rohdaten")]),
|
||||
content: Text(JsonViewer.format(dataMap)),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.of(context).pop(), child: const SingleChildScrollView(child: Text("Schließen")))
|
||||
TextButton(onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: JsonViewer.format(dataMap))).then((value) {
|
||||
showDialog(context: context, builder: (context) => const AlertDialog(content: Text("Formatiertes JSON wurde erfolgreich in deiner Zwischenlage abgelegt.")));
|
||||
});
|
||||
}, child: const Text("Kopieren")),
|
||||
TextButton(onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: dataMap.toString())).then((value) {
|
||||
showDialog(context: context, builder: (context) => const AlertDialog(content: Text("Unformatiertes JSON wurde erfolgreich in deiner Zwischenablage abgelegt.")));
|
||||
});
|
||||
}, child: const Text("Inline Kopieren")),
|
||||
TextButton(onPressed: () => Navigator.of(context).pop(), child: const Text("Schließen"))
|
||||
],
|
||||
);
|
||||
});
|
||||
|
Reference in New Issue
Block a user