From f48027324b332c7c179e68a0c6f509c51bd8e283 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 21 Jan 2021 10:58:03 +0800 Subject: [PATCH] update json format --- example/pubspec.lock | 21 +++++++++++++++++++++ lib/src/view/dio_response_view.dart | 13 +++++++++++++ lib/src/view/table_view.dart | 2 +- pubspec.lock | 21 +++++++++++++++++++++ pubspec.yaml | 2 ++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 030d376..7a86dad 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -76,6 +76,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_highlight: + dependency: transitive + description: + name: flutter_highlight + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.0" flutter_test: dependency: "direct dev" description: flutter @@ -88,6 +95,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "3.24.0" + highlight: + dependency: transitive + description: + name: highlight + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.0" http_parser: dependency: transitive description: @@ -123,6 +137,13 @@ packages: relative: true source: path version: "0.0.1" + pretty_json: + dependency: transitive + description: + name: pretty_json + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.0" sky_engine: dependency: transitive description: flutter diff --git a/lib/src/view/dio_response_view.dart b/lib/src/view/dio_response_view.dart index 62bed35..0a278ef 100644 --- a/lib/src/view/dio_response_view.dart +++ b/lib/src/view/dio_response_view.dart @@ -1,8 +1,10 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_highlight/flutter_highlight.dart'; import 'package:power_logger/src/view/box_view.dart'; import 'package:power_logger/src/view/table_view.dart'; import 'package:power_logger/src/view/title_view.dart'; +import 'package:pretty_json/pretty_json.dart'; class DioResponseView extends StatefulWidget { final Response data; @@ -51,6 +53,16 @@ class _DioResponseViewState extends State { ); } + _buildData() { + return BoxView( + title: Text('Params'), + child: HighlightView( + prettyJson(widget.data.data.toString()), + language: 'json', + ), + ); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -75,6 +87,7 @@ class _DioResponseViewState extends State { TitleView(title: Text('Response')), _buildMap(widget.data.headers.map), _buildStatus(), + _buildData(), ], ), ); diff --git a/lib/src/view/table_view.dart b/lib/src/view/table_view.dart index c6477e9..0fb620c 100644 --- a/lib/src/view/table_view.dart +++ b/lib/src/view/table_view.dart @@ -6,7 +6,7 @@ class TableView extends StatelessWidget { Widget _buildTableTitle(String title) { return Padding( padding: EdgeInsets.all(5), - child: Text(title), + child: SelectableText(title), ); } diff --git a/pubspec.lock b/pubspec.lock index 801711c..de70718 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -69,11 +69,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_highlight: + dependency: "direct main" + description: + name: flutter_highlight + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + highlight: + dependency: transitive + description: + name: highlight + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.0" http_parser: dependency: transitive description: @@ -102,6 +116,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.8.0-nullsafety.1" + pretty_json: + dependency: "direct main" + description: + name: pretty_json + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.0" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index a50a333..9dfe3e6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,6 +12,8 @@ dependencies: sdk: flutter dio: ^3.0.10 animations: ^1.1.2 + pretty_json: ^1.1.0 + flutter_highlight: ^0.6.0 dev_dependencies: flutter_test: