diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 309af34..1c922f8 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,3 +1,3 @@ { - "flutterSdkVersion": "2.0.0" + "flutterSdkVersion": "stable" } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index c6471a7..67dba15 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "dart.flutterSdkPath": "/Users/akufe/fvm/versions/2.0.0" + "dart.flutterSdkPath": "/Users/akufe/fvm/versions/stable" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c88d6f3..1ec9a0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,18 @@ # CHANGELOG +## [1.0.1-nullsafety.1] + +* add logger. + ## [1.0.0-nullsafety.0] * migrate to sound null safety. +## [0.1.4] + +* add logger. +* update example app. + ## [0.1.3] * listenable value. diff --git a/example/lib/main.dart b/example/lib/main.dart index c9f6c5e..0508638 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -49,6 +49,11 @@ class _MyHomePageState extends State { appBar: AppBar( title: Text(widget.title), ), + floatingActionButton: FloatingActionButton( + onPressed: () { + NetTool.dio.get("https://www.baidu.com"); + }, + ), ); } } diff --git a/example/pubspec.lock b/example/pubspec.lock index 91c85b1..f3e8e2f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,84 +5,84 @@ packages: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.5.0" auto_size_text: dependency: transitive description: name: auto_size_text - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "3.0.0-nullsafety.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.15.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.0.2" device_info: dependency: transitive description: name: device_info - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.0.0" device_info_platform_interface: dependency: transitive description: name: device_info_platform_interface - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.0.1" dio: dependency: "direct main" description: name: dio - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "4.0.0-prev3" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" flutter: @@ -94,7 +94,7 @@ packages: dependency: transitive description: name: flutter_highlight - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.7.0" flutter_test: @@ -106,56 +106,63 @@ packages: dependency: "direct main" description: name: get - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "3.26.0" highlight: dependency: transitive description: name: highlight - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.7.0" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "4.0.0" + logger: + dependency: transitive + description: + name: logger + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" matcher: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.0" package_info: dependency: transitive description: name: package_info - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.0.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.8.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.0.0" power_logger: @@ -164,7 +171,7 @@ packages: path: ".." relative: true source: path - version: "1.0.0-nullsafety.0" + version: "1.0.1-nullsafety.1" sky_engine: dependency: transitive description: flutter @@ -174,56 +181,56 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.2.19" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" sdks: diff --git a/lib/src/data/logger_data.dart b/lib/src/data/logger_data.dart index c6bc464..0dfa8df 100644 --- a/lib/src/data/logger_data.dart +++ b/lib/src/data/logger_data.dart @@ -1,10 +1,19 @@ import 'package:flutter/foundation.dart'; +import 'package:logger/logger.dart'; import 'package:power_logger/power_logger.dart'; /// logger data storage class LoggerData { static int _maxLength = 100; + static bool _markLogger = false; + static bool get markLogger => _markLogger; + static setLogger(bool state) { + _markLogger = state; + } + + static Logger _logger = Logger(); + /// the real logger data. static List get data => _listenableData.value; @@ -28,6 +37,8 @@ class LoggerData { _listenableData.notify(); } } + + if (_markLogger) _logger.i(data); } /// clear all logger diff --git a/lib/src/view/box_view.dart b/lib/src/view/box_view.dart index 1363e22..c47dc07 100644 --- a/lib/src/view/box_view.dart +++ b/lib/src/view/box_view.dart @@ -17,37 +17,29 @@ class BoxView extends StatelessWidget { Widget build(BuildContext context) { return Padding( padding: EdgeInsets.all(5), - child: Material( - color: Colors.white, - borderRadius: BorderRadius.circular(5), - elevation: 4, - child: Padding( - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - DefaultTextStyle( - style: TextStyle( - fontSize: 20, - color: Colors.black87, - fontWeight: FontWeight.w600, - ), - child: title, - ), - child == null ? SizedBox() : SizedBox(height: 10), - DefaultTextStyle( - style: TextStyle( - fontSize: 16, - color: Colors.black87, - fontWeight: FontWeight.w400, - ), - child: child ?? SizedBox(), - ), - children == null ? SizedBox() : SizedBox(height: 10), - ...children ?? [], - ], + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DefaultTextStyle( + style: TextStyle( + fontSize: 20, + color: Colors.black87, + fontWeight: FontWeight.w600, + ), + child: title, ), - ), + child == null ? SizedBox() : SizedBox(height: 10), + DefaultTextStyle( + style: TextStyle( + fontSize: 16, + color: Colors.black87, + fontWeight: FontWeight.w400, + ), + child: child ?? SizedBox(), + ), + children == null ? SizedBox() : SizedBox(height: 10), + ...children ?? [], + ], ), ); } diff --git a/lib/src/view/dio_error_view.dart b/lib/src/view/dio_error_view.dart index a4ea5ea..0049d60 100644 --- a/lib/src/view/dio_error_view.dart +++ b/lib/src/view/dio_error_view.dart @@ -26,7 +26,7 @@ class _DioErrorViewState extends State { _buildPath() { return BoxView( title: const Text('Path'), - child: Text(_request.path), + child: SelectableText(_request.path), ); } @@ -39,6 +39,13 @@ class _DioErrorViewState extends State { ); } + _buildMessage() { + return BoxView( + title: const Text('Message'), + child: Text(widget.data.message), + ); + } + _buildMap(dynamic params) { if (params is FormData) { Map formData = {}; @@ -76,6 +83,7 @@ class _DioErrorViewState extends State { TitleView(title: Text('Request')), _buildBaseURL(), _buildPath(), + _buildMessage(), _buildMap(_request.headers), _buildMap(_request.queryParameters), _buildMap(_request.data), diff --git a/lib/src/view/dio_response_view.dart b/lib/src/view/dio_response_view.dart index 9cac7da..0a530af 100644 --- a/lib/src/view/dio_response_view.dart +++ b/lib/src/view/dio_response_view.dart @@ -106,7 +106,7 @@ class _DioResponseViewState extends State { ), ); case ContentType.IMAGE: - return Text("IMAGE"); + return Image.network(_request.baseUrl + _request.path); case ContentType.AUDIO: return Text("AUDIO"); case ContentType.VIDEO: diff --git a/lib/src/views/settings_view.dart b/lib/src/views/settings_view.dart index 22c1feb..0e60455 100644 --- a/lib/src/views/settings_view.dart +++ b/lib/src/views/settings_view.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:power_logger/power_logger.dart'; class SettingsView extends StatefulWidget { SettingsView({Key? key}) : super(key: key); @@ -15,8 +16,11 @@ class _SettingsViewState extends State { SwitchListTile( title: Text('终端日志'), subtitle: Text(''), - value: false, - onChanged: (state) {}, + value: LoggerData.markLogger, + onChanged: (state) { + LoggerData.setLogger(state); + setState(() {}); + }, ), ], ); diff --git a/pubspec.lock b/pubspec.lock index b178bf8..34ee371 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -109,6 +109,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.0" + logger: + dependency: "direct main" + description: + name: logger + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 7a94a7c..0cea5b6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: power_logger description: A well log tool on flutter, support Dio and custom type data. -version: 1.0.0-nullsafety.0 +version: 1.0.1-nullsafety.1 homepage: https://github.com/laiiihz/power_logger environment: @@ -15,9 +15,10 @@ dependencies: device_info: ^2.0.0 package_info: ^2.0.0 auto_size_text: ^3.0.0-nullsafety.0 + logger: ^1.0.0 dev_dependencies: flutter_test: sdk: flutter -flutter: \ No newline at end of file +flutter: