From 74c57d77417ce3c17cded619abb8f0357b20fcf8 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 21 Jan 2021 13:40:29 +0800 Subject: [PATCH] fix logger parse --- lib/src/parser/data_parser.dart | 11 +++-------- lib/src/view/dio_response_view.dart | 14 +++++++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/src/parser/data_parser.dart b/lib/src/parser/data_parser.dart index 97b1076..cc061cc 100644 --- a/lib/src/parser/data_parser.dart +++ b/lib/src/parser/data_parser.dart @@ -6,13 +6,8 @@ import 'package:power_logger/src/parser/unfocus_parser.dart'; class LoggerDataParser { static Widget builder(dynamic data) { - switch (data.runtimeType) { - case DioError: - return DioErrorBuilder(data: data); - case Response: - return DioResponseBuilder(data: data); - default: - return UnfocusParser(data: data); - } + if (data is DioError) return DioErrorBuilder(data: data); + if (data is Response) return DioResponseBuilder(data: data); + return UnfocusParser(data: data); } } diff --git a/lib/src/view/dio_response_view.dart b/lib/src/view/dio_response_view.dart index 029769d..8a38e55 100644 --- a/lib/src/view/dio_response_view.dart +++ b/lib/src/view/dio_response_view.dart @@ -1,13 +1,8 @@ -import 'dart:convert'; - import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_highlight/flutter_highlight.dart'; -import 'package:flutter_highlight/themes/github.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; @@ -63,6 +58,15 @@ class _DioResponseViewState extends State { ); } + _buildSingleText(String title, String data) { + return data == null || data.length == 0 + ? SizedBox() + : BoxView( + title: Text('Params'), + child: SelectableText(data.toString()), + ); + } + @override Widget build(BuildContext context) { return Scaffold(