add PowetLogger.start api

master
小赖 4 years ago
parent 6d30dde1aa
commit cc42a73919

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

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

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