flutter_auto_api_inspector 1.2.2
flutter_auto_api_inspector: ^1.2.2 copied to clipboard
Automatic network monitoring, screen-based API debugging, interactive JSON viewer, and in-app Debug Console for Flutter across Android, iOS, and Web.
Flutter Auto API Inspector #
One Package. Complete API Visibility.
flutter_auto_api_inspector is a lightweight, zero-jank Dart/Flutter network debugging toolkit that automatically monitors HTTP API requests, groups them by the Flutter screen that triggered them (including prefetched calls!), masks sensitive credentials, prints structured Debug Console logs, and provides a responsive In-App API Inspector + Debug Console across Android, iOS, Web, and Desktop.
Mobile Visual Tour (Android 17 & iPhone 17 Pro) #
| Mobile Dashboard & Live KPIs | Screen Grouping + Prefetch Badge |
|---|---|
![]() |
![]() |
| Virtualized JSON Tree & Token Masking | Live In-App Debug Console |
![]() |
![]() |
Web & Desktop Side-Panel Tour #
| Web & Desktop Side-Panel Dashboard | Screen-Wise API Grouping + Prefetch Badge |
|---|---|
![]() |
![]() |
Key Features #
- Automatic Controller & UI Caller Origin Tracking (
v1.2.0):- Automatically identifies which Controller / Bloc / Cubit / ViewModel (
PunchListController.getLists) AND which UI Widget (PunchListScreen.initState) triggered every HTTP call — even through sharedApiProvider/Repositorywrappers! - Prints 1-click IDE jump links (
package:my_app/controllers/order_controller.dart:112:24) in VS Code & Android Studio Debug Console and renders the fullUI → Controller → APIcall chain in Request Details.
- Automatically identifies which Controller / Bloc / Cubit / ViewModel (
- Screen-Wise API Grouping & Smart Prefetch Resolution:
- Automatically tracks Flutter navigation via
ApiInspector.navigatorObserver(plus tabs viaApiInspector.setCurrentScreen()). - Captures route context at request start time so late responses stay bound to the originating screen even if the user navigates away.
- 3-Level Prefetch Priority Chain: Per-request override (
ApiInspector.screenOptions/ApiInspector.withScreen) → URL mapping rules (screenRules) → Active Route, complete with aPrefetched from <Screen>badge!
- Automatically tracks Flutter navigation via
- Multi-Client, Non-Blocking Interception:
- Mode A (Dio):
ApiInspector.attachDio(dio) - Mode B (
package:http):ApiInspector.attachHttp(http.Client())(uses a non-blocking passive stream tee —0msheader delay!) - Mode C (Managed Dio):
ApiInspector.createDio() - Optional Zero-Config Mobile (
dart:io):enableHttpOverrides: truecaptures unattacheddart:iocalls on Android/iOS/Desktop (cleanly ignored on Web).
- Mode A (Dio):
- IDE Debug Console + In-App Debug Console:
- Clean, colorized logs in VS Code / Android Studio Debug Console with O(maxChars) bounded previews.
- Built-in Console Tab inside the In-App Inspector displaying live API logs, screen transitions,
print()(viarunWithConsoleCapture), and customApiInspector.log(...)messages — even on standalone QA/TestFlight devices without a laptop!
- 60–120 FPS Virtualized JSON Tree Viewer:
- Flat virtualized
ListView.builderrenders multi-thousand-line JSON responses smoothly without UI freezes. - Collapsible/expandable objects and arrays, live key/value search with match counter, Tree / Raw toggle, Copy JSON, and one-tap Copy cURL.
- Flat virtualized
- Security-First & Release-Safe:
- Automatically disabled in release builds (
enabled: kDebugMode) — zero UI, zero logging, zero overhead in production APKs/IPAs. - Recursive masking for sensitive headers (
Authorization,Cookie,Set-Cookie,X-Api-Key) and JSON/query keys (password,token,access_token,refresh_token, etc.) across memory, console, cURL, and JSON exports.
- Automatically disabled in release builds (
Quick Start #
1. Install #
flutter pub add flutter_auto_api_inspector
2. Initialize once in main() #
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_auto_api_inspector/flutter_auto_api_inspector.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
ApiInspector.initialize(
config: const ApiInspectorConfig(
enabled: kDebugMode, // Automatically OFF in Release builds!
showConsoleLogs: true,
enableScreenTracking: true,
enableDashboard: true,
showFloatingButton: true,
maxRequests: 500,
slowRequestThreshold: Duration(milliseconds: 1000),
),
);
// Optional: mirror standard print() calls into the In-App Console tab
ApiInspector.runWithConsoleCapture(() {
runApp(const MyApp());
});
}
3. Attach Overlay & NavigatorObserver to MaterialApp #
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
builder: ApiInspector.builder,
navigatorObservers: [ApiInspector.navigatorObserver],
home: const HomeScreen(),
);
}
}
4. Connect Your HTTP Client #
// Mode A: Attach to an existing Dio instance
final dio = Dio();
ApiInspector.attachDio(dio);
// Mode B: Wrap package:http Client
final httpClient = ApiInspector.attachHttp(http.Client());
// Mode C: Create a package-managed Dio client
final managedDio = ApiInspector.createDio(
BaseOptions(baseUrl: 'https://api.example.com'),
);
5. Prefetched / Pre-loaded APIs (3-Level Screen Priority) #
When HomeScreen prefetches data for ProfileScreen or OrdersScreen, the inspector resolves the owning screen using a deterministic 3-level priority chain and displays a Prefetched from HomeScreen badge:
- Priority 1 — Per-request override (100% accurate, works for shared endpoints):
// With Dio: await dio.get( '/api/profile', options: ApiInspector.screenOptions('ProfileScreen'), ); // With package:http, Dio, or dart:io (Zone-scoped): await ApiInspector.withScreen( 'ProfileScreen', () => httpClient.get(Uri.parse('https://api.example.com/api/profile')), ); - Priority 2 — URL-to-Screen rules (automatic zero-repetition mapping):
ApiInspector.initialize( config: const ApiInspectorConfig( screenRules: { '/api/profile': 'ProfileScreen', '/api/orders/*/items': 'OrderDetailScreen', }, ), ); - Priority 3 (Default) — Active Route from
ApiInspector.navigatorObserver/ApiInspector.setCurrentScreen().
6. Optional: Tabs, Nested Navigators & GoRouter #
// For BottomNavigationBar / IndexedStack tabs:
ApiInspector.setCurrentScreen('OrdersTab');
// For GoRouter or nested navigators:
final shellObserver = ApiInspector.createNavigatorObserver(
navigatorName: 'OrdersShell',
);
Sensitive Data Masking #
Sensitive fields are masked automatically before storage, console output, cURL generation, and JSON export:
ApiInspector.initialize(
config: const ApiInspectorConfig(
sensitiveHeaders: ['authorization', 'cookie', 'set-cookie', 'x-api-key'],
sensitiveKeys: ['password', 'token', 'access_token', 'refresh_token'],
),
);
Platform Support #
| Platform | Status | Notes |
|---|---|---|
| Android | Full | Full-screen inspector + draggable floating pill + optional HttpOverrides |
| iOS | Full | Full-screen inspector + draggable floating pill + optional HttpOverrides |
| Web | Full | Docked side-panel on wide viewports (host app stays interactive!) + full-screen on mobile web |
| macOS / Windows / Linux | Full | Responsive side-panel & split-view inspection |
License #
MIT License — Copyright (c) 2026 Muhammad Abid. See LICENSE for details.






