themisir / flutter-network-logger

Network logger with well designed user interface to inspect network traffic logs. Included with Dio interceptor.
https://pub.dev/packages/network_logger
Apache License 2.0
25 stars 21 forks source link

遇到一个错误 #17

Open 315909433 opened 1 year ago

315909433 commented 1 year ago

Unhandled Exception: Navigator operation requested with a context that does not include a Navigator. The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget. E/flutter (10919): #0 Navigator.of. (package:flutter/src/widgets/navigator.dart:2607:9) E/flutter (10919): #1 Navigator.of (package:flutter/src/widgets/navigator.dart:2614:6) E/flutter (10919): #2 Navigator.push (package:flutter/src/widgets/navigator.dart:2072:22) E/flutter (10919): #3 NetworkLoggerScreen.open (package:network_logger/src/ui.dart:263:22) E/flutter (10919): #4 _NetworkLoggerButtonState._press (package:network_logger/src/ui.dart:179:33) E/flutter (10919): #5 _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1096:21) E/flutter (10919): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:253:24) E/flutter (10919): #7 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:627:11) E/flutter (10919): #8 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:306:5) E/flutter (10919): #9 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:276:7) E/flutter (10919): #10 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:163:27) E/flutter (10919): #11 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:464:20) E/flutter (10919): #12 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:440:22) E/flutter (10919): #13 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:336:11) E/flutter (10919): #14 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:395:7) E/flutter (10919): #15 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:357:5) E/flutter (10919): #16 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:314:7) E/flutter (10919): #17 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:295:7) E/flutter (10919): #18 _invoke1 (dart:ui/hooks.dart:164:13) E/flutter (10919): #19 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:361:7) E/flutter (10919): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:91:31)

themisir commented 1 year ago

Can you please provide a code sample on how you are trying to use the plugin?

315909433 commented 1 year ago

Can you please provide a code sample on how you are trying to use the plugin?

HttpManager._internal() { _dio = Dio(BaseOptions( baseUrl: _hostUrl, connectTimeout: 60 1000, sendTimeout: 60 1000, receiveTimeout: 60 * 1000, contentType: Headers.jsonContentType)) ..interceptors.addAll([DioNetworkLogger(),]); }

======= MainPage.dart

void initState() { super.initState(); NetworkLoggerOverlay.attachTo(context); }

themisir commented 1 year ago

Alright, I am not 100% familiar with the latest updates on the framework. Maybe last versions somehow break how network overlay worked in the past. I will investigate this when I got some spare time.

For now I would suggest using NetworkLoggerButton as a floating action button on the Scaffold widget. Or you can call NetworkLoggerScreen.open(context) to open the logger screen from anywhere without having to use any specific widget on the UI.

315909433 commented 1 year ago

Alright, I am not 100% familiar with the latest updates on the framework. Maybe last versions somehow break how network overlay worked in the past. I will investigate this when I got some spare time.

For now I would suggest using NetworkLoggerButton as a floating action button on the Scaffold widget. Or you can call NetworkLoggerScreen.open(context) to open the logger screen from anywhere without having to use any specific widget on the UI.

Okay, I'll give it a try