Compare commits
3 Commits
103a334c84
...
509aae27df
| Author | SHA1 | Date |
|---|---|---|
|
|
509aae27df | |
|
|
c02486e072 | |
|
|
747dba216f |
|
|
@ -39,10 +39,6 @@ class YxNetInspectorController extends ChangeNotifier {
|
|||
void initialize(YxNetInspectorConfig config) {
|
||||
_config = config;
|
||||
_showFloatingBall = config.showFloatingBall;
|
||||
|
||||
if (kDebugMode) {
|
||||
debugPrint('🔍 YX 网络检查器已初始化');
|
||||
}
|
||||
}
|
||||
|
||||
/// 记录网络请求
|
||||
|
|
@ -72,10 +68,6 @@ class YxNetInspectorController extends ChangeNotifier {
|
|||
_requestCount++;
|
||||
_trimLogs();
|
||||
notifyListeners();
|
||||
|
||||
if (kDebugMode) {
|
||||
debugPrint('📡 请求已记录: $method $url');
|
||||
}
|
||||
}
|
||||
|
||||
/// 记录网络响应
|
||||
|
|
@ -117,12 +109,6 @@ class YxNetInspectorController extends ChangeNotifier {
|
|||
}
|
||||
|
||||
notifyListeners();
|
||||
|
||||
if (kDebugMode) {
|
||||
debugPrint(
|
||||
'📨 响应已记录: $statusCode for ${originalLog.method} ${originalLog.url}',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 记录网络错误
|
||||
|
|
@ -154,12 +140,6 @@ class YxNetInspectorController extends ChangeNotifier {
|
|||
}
|
||||
|
||||
notifyListeners();
|
||||
|
||||
if (kDebugMode) {
|
||||
debugPrint(
|
||||
'❌ 错误已记录: $error for ${originalLog.method} ${originalLog.url}',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 清空所有日志
|
||||
|
|
@ -170,10 +150,6 @@ class YxNetInspectorController extends ChangeNotifier {
|
|||
_errorCount = 0;
|
||||
_totalDuration = 0;
|
||||
notifyListeners();
|
||||
|
||||
if (kDebugMode) {
|
||||
debugPrint('🧹 所有日志已清空');
|
||||
}
|
||||
}
|
||||
|
||||
/// 显示悬浮球
|
||||
|
|
|
|||
|
|
@ -96,18 +96,12 @@ class _YxFloatingBallState extends State<YxFloatingBall>
|
|||
OverlayState? overlay;
|
||||
try {
|
||||
overlay = Overlay.of(context, rootOverlay: true);
|
||||
print('YxNetInspector: 成功找到根 Overlay');
|
||||
} catch (e) {
|
||||
print('YxNetInspector: 根 Overlay 查找失败: $e');
|
||||
debugPrint('YxNetInspector: 根 Overlay 查找失败: $e');
|
||||
// 如果 Overlay.of 失败,尝试手动查找
|
||||
overlay = _findOverlayInContext(context);
|
||||
if (overlay != null) {
|
||||
print('YxNetInspector: 手动查找 Overlay 成功');
|
||||
} else {
|
||||
print('YxNetInspector: 手动查找 Overlay 也失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (overlay == null) {
|
||||
// 如果仍然找不到 Overlay,使用备选方案
|
||||
_showInspectorDialog();
|
||||
|
|
@ -144,9 +138,8 @@ class _YxFloatingBallState extends State<YxFloatingBall>
|
|||
|
||||
overlay.insert(overlayEntry);
|
||||
_currentOverlayEntry = overlayEntry;
|
||||
print('YxNetInspector: 检查器面板显示成功');
|
||||
} catch (e) {
|
||||
print('YxNetInspector: 插入 OverlayEntry 失败: $e');
|
||||
debugPrint('YxNetInspector: 插入 OverlayEntry 失败: $e');
|
||||
// 重置状态
|
||||
setState(() {
|
||||
_isExpanded = false;
|
||||
|
|
@ -176,8 +169,7 @@ class _YxFloatingBallState extends State<YxFloatingBall>
|
|||
void _createCustomOverlay() {
|
||||
// 如果所有 Overlay 方法都失败,我们显示一个简单的调试信息
|
||||
// 并重置状态,避免悬浮球卡在展开状态
|
||||
print('YxNetInspector: 无法找到 Overlay 上下文,请确保 YxNetInspector 在 MaterialApp 内部使用');
|
||||
|
||||
|
||||
// 显示一个简单的 SnackBar 或 print 提示
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
|
|
@ -190,9 +182,9 @@ class _YxFloatingBallState extends State<YxFloatingBall>
|
|||
);
|
||||
} catch (e) {
|
||||
// 如果 ScaffoldMessenger 也不可用,只打印日志
|
||||
print('YxNetInspector: 无法显示检查器面板 - 请确保在 MaterialApp 内使用');
|
||||
debugPrint('YxNetInspector: 无法显示检查器面板 - 请确保在 MaterialApp 内使用');
|
||||
}
|
||||
|
||||
|
||||
// 重置状态
|
||||
setState(() {
|
||||
_isExpanded = false;
|
||||
|
|
|
|||
|
|
@ -66,10 +66,6 @@ class _YxNetInspectorState extends State<YxNetInspector> {
|
|||
// 初始化控制器
|
||||
_controller = YxNetInspectorController.instance;
|
||||
_controller.initialize(widget.config);
|
||||
|
||||
if (kDebugMode) {
|
||||
debugPrint('🔍 YX Net Inspector: App wrapper initialized');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
16
pubspec.lock
16
pubspec.lock
|
|
@ -54,14 +54,6 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
|
|
@ -91,14 +83,6 @@ packages:
|
|||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
42
pubspec.yaml
42
pubspec.yaml
|
|
@ -1,6 +1,6 @@
|
|||
name: yx_net_inspector
|
||||
description: A powerful network inspector with floating debug ball for Flutter apps. Monitor HTTP requests, responses, and debug network issues in real-time.
|
||||
version: 1.0.0
|
||||
version: 1.0.2
|
||||
homepage: https://github.com/your-username/yx_net_inspector
|
||||
|
||||
environment:
|
||||
|
|
@ -10,47 +10,9 @@ environment:
|
|||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
# 可选依赖:如果使用Dio拦截器,请添加dio依赖
|
||||
# dio: ^5.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^4.0.0
|
||||
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter packages.
|
||||
flutter:
|
||||
|
||||
# To add assets to your package, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
#
|
||||
# For details regarding assets in packages, see
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
#
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
||||
|
||||
# To add custom fonts to your package, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts in packages, see
|
||||
# https://flutter.dev/custom-fonts/#from-packages
|
||||
|
|
|
|||
Loading…
Reference in New Issue