fix context err

master
小赖 4 years ago
parent ef1db90821
commit 050d008c5d

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

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

@ -5,84 +5,84 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.5.0" version: "2.5.0"
auto_size_text: auto_size_text:
dependency: transitive dependency: transitive
description: description:
name: auto_size_text name: auto_size_text
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0-nullsafety.0" version: "3.0.0-nullsafety.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
name: cupertino_icons name: cupertino_icons
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.0.2"
device_info: device_info:
dependency: transitive dependency: transitive
description: description:
name: device_info name: device_info
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
device_info_platform_interface: device_info_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: device_info_platform_interface name: device_info_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
dio: dio:
dependency: "direct main" dependency: "direct main"
description: description:
name: dio name: dio
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.0.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
flutter: flutter:
@ -94,7 +94,7 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: flutter_highlight name: flutter_highlight
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.7.0" version: "0.7.0"
flutter_test: flutter_test:
@ -106,63 +106,63 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: get name: get
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.1.4" version: "4.1.4"
highlight: highlight:
dependency: transitive dependency: transitive
description: description:
name: highlight name: highlight
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.7.0" version: "0.7.0"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
name: http_parser name: http_parser
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.0.0"
logger: logger:
dependency: transitive dependency: transitive
description: description:
name: logger name: logger
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.10" version: "0.12.10"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
package_info: package_info:
dependency: transitive dependency: transitive
description: description:
name: package_info name: package_info
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
power_logger: power_logger:
@ -171,7 +171,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "1.1.0" version: "1.1.1-nullsafety.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -181,56 +181,56 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.19" version: "0.2.19"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
sdks: sdks:

@ -1,14 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:power_logger/src/widgets/logger_fab.dart'; import 'package:power_logger/src/widgets/logger_fab.dart';
class PowerLogger { class PowerLogger {
/// debug tag /// debug tag
static bool debug = true; static bool debug = true;
static OverlayEntry? entry;
static late BuildContext globalContext;
/// ///
/// ///
///debug ///debug
@ -19,8 +16,7 @@ class PowerLogger {
@Deprecated("use PowerLogger.start") @Deprecated("use PowerLogger.start")
static init(BuildContext context, {bool debug = true}) { static init(BuildContext context, {bool debug = true}) {
PowerLogger.debug = debug; PowerLogger.debug = debug;
globalContext = context; if (debug) if (debug) _insertToOverlay(context);
if (debug) if (debug) _insertToOverlay();
} }
/// ///
@ -35,28 +31,20 @@ class PowerLogger {
bool debug = true, bool debug = true,
Alignment initAlignment = Alignment.center, Alignment initAlignment = Alignment.center,
}) { }) {
globalContext = context; PowerLogger.debug = debug;
WidgetsBinding.instance!.addPostFrameCallback((_) { SchedulerBinding.instance!.addPostFrameCallback((_) {
PowerLogger.debug = debug; if (debug) _insertToOverlay(context, initAlignment: initAlignment);
if (debug) _insertToOverlay(initAlignment: initAlignment);
}); });
} }
static _insertToOverlay({Alignment initAlignment = Alignment.center}) { static _insertToOverlay(
entry = OverlayEntry( BuildContext context, {
Alignment initAlignment = Alignment.center,
}) {
Overlay.of(context)!.insert(OverlayEntry(
builder: (context) { builder: (context) {
return LoggerFab(initAlignment: initAlignment); 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); const SpringDescription(mass: 15, stiffness: 1000, damping: 0.7);
Alignment get alignment => _dragAlignment; Alignment get alignment => _dragAlignment;
bool opened = false;
double _normalizeVelocity(Offset velocity, Size size) { double _normalizeVelocity(Offset velocity, Size size) {
final normalizedVelocity = Offset( final normalizedVelocity = Offset(
velocity.dx / size.width, velocity.dx / size.width,
@ -78,13 +80,17 @@ class LoggerFabState extends State<LoggerFab>
onPanEnd: (details) => onPanEnd: (details) =>
_runAnimation(details.velocity.pixelsPerSecond, size), _runAnimation(details.velocity.pixelsPerSecond, size),
onTap: () async { onTap: () async {
Alignment initAlignment = _dragAlignment; if (!opened) {
PowerLogger.removeFromOverlay(); opened = true;
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => PowerLoggerView()), MaterialPageRoute(builder: (context) => PowerLoggerView()),
); );
PowerLogger.insertToOverlay(initAlignment: initAlignment); opened = false;
} else {
opened = false;
Navigator.pop(context);
}
}, },
child: const _FabButton(), child: const _FabButton(),
), ),

@ -5,77 +5,77 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.5.0" version: "2.5.0"
auto_size_text: auto_size_text:
dependency: "direct main" dependency: "direct main"
description: description:
name: auto_size_text name: auto_size_text
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0-nullsafety.0" version: "3.0.0-nullsafety.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0"
device_info: device_info:
dependency: "direct main" dependency: "direct main"
description: description:
name: device_info name: device_info
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
device_info_platform_interface: device_info_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: device_info_platform_interface name: device_info_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
dio: dio:
dependency: "direct main" dependency: "direct main"
description: description:
name: dio name: dio
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.0.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
flutter: flutter:
@ -87,7 +87,7 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_highlight name: flutter_highlight
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.7.0" version: "0.7.0"
flutter_test: flutter_test:
@ -99,56 +99,56 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: highlight name: highlight
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.7.0" version: "0.7.0"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
name: http_parser name: http_parser
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.0.0"
logger: logger:
dependency: "direct main" dependency: "direct main"
description: description:
name: logger name: logger
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.10" version: "0.12.10"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
package_info: package_info:
dependency: "direct main" dependency: "direct main"
description: description:
name: package_info name: package_info
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
sky_engine: sky_engine:
@ -160,56 +160,56 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.19" version: "0.2.19"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
sdks: sdks:

@ -1,6 +1,6 @@
name: power_logger name: power_logger
description: A well log tool on flutter, support Dio and custom type data. 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 homepage: https://github.com/laiiihz/power_logger
environment: environment:

Loading…
Cancel
Save