update document & update readme file

master
小赖 4 years ago
parent e19a619b20
commit f7546253d0

@ -1,14 +1,30 @@
# power_logger
A new Flutter package.
A well log tool on flutter, support Dio and custom type data.
## Getting Started
This project is a starting point for a Dart
[package](https://flutter.dev/developing-packages/),
a library module containing code that can be shared easily across
multiple Flutter or Dart projects.
### Usage
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
* init logger
```dart
Future.delayed(
Duration(milliseconds: 300),
() => PowerLogger.init(context),
);
```
* add data to logger
```dart
LoggerData.addData(data);
```
## WARNING
*only tested on flutter 1.22.5
## author
[laiiihz](https://github.com/laiiihz)

@ -2,6 +2,7 @@ import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:power_logger/src/view/dio_error_view.dart';
///Dio Error builder
class DioErrorBuilder extends StatefulWidget {
final DioError data;
DioErrorBuilder({Key key, @required this.data}) : super(key: key);

@ -2,6 +2,7 @@ import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:power_logger/src/view/dio_response_view.dart';
/// Dio Response Builder
class DioResponseBuilder extends StatefulWidget {
final Response data;
DioResponseBuilder({Key key, this.data}) : super(key: key);

@ -1,15 +1,20 @@
import 'package:power_logger/power_logger.dart';
/// logger data storage
class LoggerData {
static int _maxLength = 100;
static List<dynamic> _data = [];
/// the real logger data.
static List<dynamic> get data => _data;
/// set the logger max number.
static setMax(int max) {
_maxLength = max ?? 100;
}
/// add data to logger
static addData(dynamic data) {
if (PowerLogger.debug) {
if (_data.length < _maxLength)
@ -21,5 +26,6 @@ class LoggerData {
}
}
/// clear all logger
static clear() => _data.clear();
}

@ -4,6 +4,7 @@ import 'package:power_logger/src/builders/dio_responses_builder.dart';
import 'package:power_logger/src/builders/dio_error_builder.dart';
import 'package:power_logger/src/parser/unfocus_parser.dart';
///LoggerDataParser
class LoggerDataParser {
static Widget builder(dynamic data) {
if (data is DioError) return DioErrorBuilder(data: data);

@ -1,5 +1,6 @@
import 'package:dio/dio.dart';
/// original http content type.
enum ContentType {
TEXT_PLAIN,
TEXT_HTML,
@ -12,13 +13,20 @@ enum ContentType {
UNCATCH,
}
/// Dio parse
class DioParser {
Response _response;
DioParser(Response response) {
_response = response;
}
/// get dio request
RequestOptions get request => _response.request;
/// get dio response
Response get response => _response;
/// get dio contentType
ContentType get type {
String _ctype = response.headers.map['content-type'].first;
switch (_ctype) {
@ -42,6 +50,7 @@ class DioParser {
return ContentType.UNCATCH;
}
/// get highlight type.
String get highlight {
switch (type) {
case ContentType.TEXT_HTML:

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
/// UnfocusParser
class UnfocusParser extends StatelessWidget {
final dynamic data;
const UnfocusParser({Key key, @required this.data}) : super(key: key);

@ -4,11 +4,16 @@ import 'package:flutter/material.dart';
import 'package:power_logger/power_logger.dart';
class PowerLogger {
/// debug tag
static bool debug = true;
///
///
///debug
///
///```dart
///PowerLogger.init(context,debug:true);
///```
static init(BuildContext context, {bool debug = true}) {
PowerLogger.debug = debug;
if (debug)
@ -20,6 +25,7 @@ class PowerLogger {
}
}
///Logger FAB
class LoggerFAB extends StatefulWidget {
LoggerFAB({Key key}) : super(key: key);

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:power_logger/power_logger.dart';
///Logger view
class PowerLoggerView extends StatefulWidget {
PowerLoggerView({Key key}) : super(key: key);

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
///BoxView
class BoxView extends StatelessWidget {
final Widget title;
final Widget child;

Loading…
Cancel
Save