add PowetLogger.start api

master
小赖 4 years ago
parent 6d30dde1aa
commit cc42a73919

@ -23,7 +23,7 @@ LoggerData.addData(data);
## WARNING ## WARNING
*only tested on flutter 1.22.5 *only tested on flutter `1.22.5`,`1.22.6`
## author ## author

@ -51,10 +51,7 @@ class _MyHomePageState extends State<MyHomePage> {
.then((e) { .then((e) {
LoggerData.addData(e); LoggerData.addData(e);
}); });
Future.delayed( PowerLogger.start(context);
Duration(milliseconds: 300),
() => PowerLogger.init(context),
);
LoggerData.addData('TEST'); LoggerData.addData('TEST');
} }

@ -1,7 +1,6 @@
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:power_logger/power_logger.dart';
import 'package:power_logger/src/widgets/logger_fab.dart'; import 'package:power_logger/src/widgets/logger_fab.dart';
class PowerLogger { class PowerLogger {
@ -15,13 +14,31 @@ class PowerLogger {
///```dart ///```dart
///PowerLogger.init(context,debug:true); ///PowerLogger.init(context,debug:true);
///``` ///```
@Deprecated("use PowerLogger.start")
static init(BuildContext context, {bool debug = true}) { static init(BuildContext context, {bool debug = true}) {
PowerLogger.debug = debug; PowerLogger.debug = debug;
if (debug) if (debug) if (debug) _insertToOverlay(context);
Overlay.of(context).insert(OverlayEntry( }
builder: (context) {
return LoggerFab(); ///
}, ///
)); ///debug
///
///```dart
///PowerLogger.start(context,debug:true);
///```
static start(BuildContext context, {bool debug = true}) {
WidgetsBinding.instance.addPostFrameCallback((_) {
PowerLogger.debug = debug;
if (debug) _insertToOverlay(context);
});
}
static _insertToOverlay(BuildContext context) {
Overlay.of(context).insert(OverlayEntry(
builder: (context) {
return LoggerFab();
},
));
} }
} }

Loading…
Cancel
Save