Getting Started / 快速开始
Quick Start / 快速开始
Integrate with just 1 line of code:
仅需 1 行代码 即可完成集成:
import 'package:flutter/material.dart';
import 'package:zero_inspector_kit/zero_inspector_kit.dart';
void main() {
// Single line: Initialize inspector, capture print() via Zone, and display floating button
// 一行代码:初始化检查器、通过 Zone 捕获 print()、自动显示悬浮按钮
ZeroInspectorKit.runAppWithInspector(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('App')),
body: const Center(child: Text('Hello World')),
),
);
}
}What Happens Automatically / 自动完成的工作
After integration, the inspector automatically does the following without modifying any other project code:
集成后,检查器会自动完成以下工作,无需修改项目其他代码:
| Feature | Description |
|---|---|
| ✅ Log Capture | Auto-capture all print(), debugPrint() via Zone / 通过 Zone 自动捕获所有日志 |
| ✅ Network Interception | Auto-intercept all http and Dio requests via HttpOverrides / 自动拦截所有网络请求 |
| ✅ Error Capture | Aggregate Flutter framework errors & unhandled exceptions, deduped by type + stack (Errors tab) / 聚合 Flutter 框架异常与未捕获异常,按类型+堆栈去重 |
| ✅ Session Persistence | Flush logs/network/errors to a disk ring buffer; logs & errors replay on next launch / 日志/网络/异常落盘环形缓冲,启动时回放日志与异常 |
| ✅ Database Scan | Auto-scan and register SQLite databases / 自动扫描注册数据库 |
| ✅ Floating Button | Auto-displayed via Overlay, not affected by keyboard / 通过 Overlay 自动显示 |
| ✅ Route Tracking | Auto-inject InspectorRouteObserver into MaterialApp / 自动注入路由观察者 |
Note / 说明: The Memory and FPS panels are available as tabs but are off by default to avoid performance overhead. Toggle the switch at the top of each panel to start collecting data. See Memory Viewer and FPS Viewer for details.
Memory 和 FPS 面板作为标签页可用,但默认关闭以避免性能开销。在各自面板顶部打开开关才会开始采集数据。详见 Memory Viewer 和 FPS Viewer。
Pre-initialized binding / 提前初始化的 binding: If you call
WidgetsFlutterBinding.ensureInitialized()orawaita platform-channel plugin (e.g.SharedPreferences) beforerunAppWithInspector(), the binding is already initialized. In that caserunAppWithInspector()degrades gracefully to a plainrunApp()(capturingdebugPrintlogs, but not rawprint()) instead of throwing a “Zone mismatch” assertion. No extra setup is needed.binding 已提前初始化:如果你在
runAppWithInspector()之前调用了WidgetsFlutterBinding.ensureInitialized()或await了会触发 platform channel 的插件(如SharedPreferences),binding 已被初始化。此时runAppWithInspector()会优雅降级为普通runApp()(仍捕获debugPrint日志,但不捕获原始print()),而非抛出 “Zone mismatch” 断言。无需额外处理。
Production Build / 生产构建
The inspector is automatically disabled in release mode. You don’t need to remove any code — Flutter’s tree-shaking will remove all inspector-related code from production builds.
检查器在 release 模式下会自动禁用,无需移除任何代码,Flutter 的 tree-shaking 会自动移除所有检查器相关代码。
Alternative Integration / 替代集成方式
If you prefer more control, use the two-line approach:
如果需要更多控制权,可以使用两行代码方式:
void main() {
ZeroInspectorKit.init();
runApp(ZeroInspectorKit.wrapApp(const MyApp()));
}Next Steps / 下一步
- Installation — Detailed installation methods / 详细安装方式
- Usage — Full usage guide / 完整使用指南
- Configuration — Configuration options / 配置选项