diff --git a/example/pubspec.lock b/example/pubspec.lock index 3e3ab69..299279a 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -165,13 +165,6 @@ packages: relative: true source: path version: "0.1.3" - 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/external_lib/pretty_json.dart b/lib/external_lib/pretty_json.dart new file mode 100644 index 0000000..9831967 --- /dev/null +++ b/lib/external_lib/pretty_json.dart @@ -0,0 +1,7 @@ +import 'dart:convert'; + +String prettyJson(dynamic json, {int indent = 2}) { + var spaces = ' ' * indent; + var encoder = JsonEncoder.withIndent(spaces); + return encoder.convert(json); +} \ No newline at end of file diff --git a/lib/src/view/dio_response_view.dart b/lib/src/view/dio_response_view.dart index 7bedae1..543e8c1 100644 --- a/lib/src/view/dio_response_view.dart +++ b/lib/src/view/dio_response_view.dart @@ -5,11 +5,11 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_highlight/flutter_highlight.dart'; import 'package:flutter_highlight/themes/atom-one-light.dart'; +import 'package:power_logger/external_lib/pretty_json.dart'; import 'package:power_logger/src/parser/dio_parser/dio_parser.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'; // enum diff --git a/lib/src/views/info_view.dart b/lib/src/views/info_view.dart index 97af09a..bb388af 100644 --- a/lib/src/views/info_view.dart +++ b/lib/src/views/info_view.dart @@ -35,15 +35,14 @@ class _InfoViewState extends State elevation: 2, onPressed: () {}, onLongPress: () { - Scaffold.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); Clipboard.setData(ClipboardData(text: subTitle)); - Scaffold.of(context).showSnackBar(SnackBar( + ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text('已复制'), action: SnackBarAction( label: '确定', - onPressed: () { - Scaffold.of(context).hideCurrentSnackBar(); - }, + onPressed: () => + ScaffoldMessenger.of(context).hideCurrentSnackBar(), ), )); }, @@ -76,15 +75,14 @@ class _InfoViewState extends State title: Text(title), subtitle: Text(subTitle ?? ''), onLongPress: () { - Scaffold.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); Clipboard.setData(ClipboardData(text: subTitle)); - Scaffold.of(context).showSnackBar(SnackBar( + ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text('已复制'), action: SnackBarAction( label: '确定', - onPressed: () { - Scaffold.of(context).hideCurrentSnackBar(); - }, + onPressed: () => + ScaffoldMessenger.of(context).hideCurrentSnackBar(), ), )); }, diff --git a/pubspec.lock b/pubspec.lock index bb6cc5c..249c799 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -144,13 +144,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.0" - 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 742be08..3ad6247 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,6 @@ dependencies: flutter: sdk: flutter dio: ^4.0.0-prev3 - pretty_json: ^1.1.0 flutter_highlight: ^0.7.0 device_info: ^2.0.0 package_info: ^2.0.0