Pretty JSON and extended Webuntis Error Handling
This commit is contained in:
@ -59,16 +59,14 @@ class _DebugOverviewState extends State<DebugOverview> {
|
||||
itemCount: files.length,
|
||||
itemBuilder: (context, index) {
|
||||
String filename = files[index].split("/").last;
|
||||
//String data = getValue(index).toString().replaceAll("{", "{\n ").replaceAll("[", "[\n ").replaceAll(",", ",\n ");
|
||||
String data = getValue(index).toString();
|
||||
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.text_snippet_outlined),
|
||||
title: Text("(${data.length} z) [$filename] ${Jiffy.unixFromMillisecondsSinceEpoch(getValue(index)['lastupdate']).fromNow()}"),
|
||||
title: Text("(${getValue(index).toString().length} z) [$filename] ${Jiffy.unixFromMillisecondsSinceEpoch(getValue(index)['lastupdate']).fromNow()}"),
|
||||
textColor: Colors.black,
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||
return JsonViewer(title: filename, data: data);
|
||||
return JsonViewer(title: filename, data: getValue(index));
|
||||
},));
|
||||
},
|
||||
);
|
||||
|
@ -1,8 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pretty_json/pretty_json.dart';
|
||||
|
||||
class JsonViewer extends StatelessWidget {
|
||||
String title;
|
||||
String data;
|
||||
Map<String, dynamic> data;
|
||||
|
||||
JsonViewer({Key? key, required this.title, required this.data}) : super(key: key);
|
||||
|
||||
@ -14,8 +15,13 @@ class JsonViewer extends StatelessWidget {
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Text(data.replaceAllMapped(RegExp(r'[{,}]'), (match) => "${match.group(0)}\n ")),
|
||||
child: Text(format(data)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static String format(Map<String, dynamic> jsonInput) {
|
||||
return prettyJson(jsonInput, indent: 2);
|
||||
//return jsonInput.replaceAllMapped(RegExp(r'[{,}]'), (match) => "${match.group(0)}\n ");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user