fix context err

master
小赖 4 years ago
parent ef1db90821
commit 050d008c5d

@ -1,5 +1,9 @@
# CHANGELOG
## [1.1.1-nullsafety.3]
* fix context error.
## [1.1.0-nullsafety.2]
* performance enhanced.

@ -77,7 +77,7 @@ class _MyHomePageState extends State<MyHomePage> {
: () async {
loading = true;
setState(() {});
await NetTool.dio.get(_textController.text).catchError((e) {});
await NetTool.dio.get(_textController.text).catchError((_) {});
loading = false;
setState(() {});
},

@ -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"
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,63 +106,63 @@ packages:
dependency: "direct main"
description:
name: get
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.4"
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.flutter-io.cn"
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:
@ -171,7 +171,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.1.0"
version: "1.1.1-nullsafety.3"
sky_engine:
dependency: transitive
description: flutter
@ -181,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:

@ -1,14 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:power_logger/src/widgets/logger_fab.dart';
class PowerLogger {
/// debug tag
static bool debug = true;
static OverlayEntry? entry;
static late BuildContext globalContext;
///
///
///debug
@ -19,8 +16,7 @@ class PowerLogger {
@Deprecated("use PowerLogger.start")
static init(BuildContext context, {bool debug = true}) {
PowerLogger.debug = debug;
globalContext = context;
if (debug) if (debug) _insertToOverlay();
if (debug) if (debug) _insertToOverlay(context);
}
///
@ -35,28 +31,20 @@ class PowerLogger {
bool debug = true,
Alignment initAlignment = Alignment.center,
}) {
globalContext = context;
WidgetsBinding.instance!.addPostFrameCallback((_) {
PowerLogger.debug = debug;
if (debug) _insertToOverlay(initAlignment: initAlignment);
PowerLogger.debug = debug;
SchedulerBinding.instance!.addPostFrameCallback((_) {
if (debug) _insertToOverlay(context, initAlignment: initAlignment);
});
}
static _insertToOverlay({Alignment initAlignment = Alignment.center}) {
entry = OverlayEntry(
static _insertToOverlay(
BuildContext context, {
Alignment initAlignment = Alignment.center,
}) {
Overlay.of(context)!.insert(OverlayEntry(
builder: (context) {
return LoggerFab(initAlignment: initAlignment);
},
);
Overlay.of(globalContext)!.insert(entry!);
}
static insertToOverlay({Alignment initAlignment = Alignment.center}) =>
_insertToOverlay(
initAlignment: initAlignment,
);
static removeFromOverlay() {
if (entry != null) entry!.remove();
));
}
}

@ -21,6 +21,8 @@ class LoggerFabState extends State<LoggerFab>
const SpringDescription(mass: 15, stiffness: 1000, damping: 0.7);
Alignment get alignment => _dragAlignment;
bool opened = false;
double _normalizeVelocity(Offset velocity, Size size) {
final normalizedVelocity = Offset(
velocity.dx / size.width,
@ -78,13 +80,17 @@ class LoggerFabState extends State<LoggerFab>
onPanEnd: (details) =>
_runAnimation(details.velocity.pixelsPerSecond, size),
onTap: () async {
Alignment initAlignment = _dragAlignment;
PowerLogger.removeFromOverlay();
await Navigator.push(
context,
MaterialPageRoute(builder: (context) => PowerLoggerView()),
);
PowerLogger.insertToOverlay(initAlignment: initAlignment);
if (!opened) {
opened = true;
await Navigator.push(
context,
MaterialPageRoute(builder: (context) => PowerLoggerView()),
);
opened = false;
} else {
opened = false;
Navigator.pop(context);
}
},
child: const _FabButton(),
),

@ -5,77 +5,77 @@ 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: "direct main"
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"
device_info:
dependency: "direct main"
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"
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:
@ -87,7 +87,7 @@ packages:
dependency: "direct main"
description:
name: flutter_highlight
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.0"
flutter_test:
@ -99,56 +99,56 @@ packages:
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: "direct main"
description:
name: logger
url: "https://pub.flutter-io.cn"
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: "direct main"
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"
sky_engine:
@ -160,56 +160,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:

@ -1,6 +1,6 @@
name: power_logger
description: A well log tool on flutter, support Dio and custom type data.
version: 1.1.0-nullsafety.2
version: 1.1.1-nullsafety.3
homepage: https://github.com/laiiihz/power_logger
environment:

Loading…
Cancel
Save