Skip to main content

flutter_auto_api_inspector 1.2.0 copy "flutter_auto_api_inspector: ^1.2.0" to clipboard
flutter_auto_api_inspector: ^1.2.0 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 #

pub package pub points likes CI License: MIT

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.

Android 17 Emulator and iPhone 17 Pro Simulator Live Walkthrough


Mobile Visual Tour (Android 17 & iPhone 17 Pro) #

Mobile Dashboard & Live KPIs Screen Grouping + Prefetch Badge
Mobile Dashboard and KPIs on Android and iOS Screen-Wise API Grouping and Prefetch Badges on Android and iOS
Virtualized JSON Tree & Token Masking Live In-App Debug Console
JSON Tree Viewer and Sensitive Masking on Android and iOS In-App Debug Console on Android and iOS

Web & Desktop Side-Panel Tour #

Web and Desktop Side-Panel Walkthrough

Web & Desktop Side-Panel Dashboard Screen-Wise API Grouping + Prefetch Badge
Dashboard & Web Side Panel Screen-Wise API Grouping

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 shared ApiProvider / Repository wrappers!
    • 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 full UI → Controller → API call chain in Request Details.
  • Screen-Wise API Grouping & Smart Prefetch Resolution:
    • Automatically tracks Flutter navigation via ApiInspector.navigatorObserver (plus tabs via ApiInspector.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 a Prefetched from <Screen> badge!
  • 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 — 0ms header delay!)
    • Mode C (Managed Dio): ApiInspector.createDio()
    • Optional Zero-Config Mobile (dart:io): enableHttpOverrides: true captures unattached dart:io calls on Android/iOS/Desktop (cleanly ignored on Web).
  • 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() (via runWithConsoleCapture), and custom ApiInspector.log(...) messages — even on standalone QA/TestFlight devices without a laptop!
  • 60–120 FPS Virtualized JSON Tree Viewer:
    • Flat virtualized ListView.builder renders 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.
  • 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.

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:

  1. 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')),
    );
    
  2. Priority 2 — URL-to-Screen rules (automatic zero-repetition mapping):
    ApiInspector.initialize(
      config: const ApiInspectorConfig(
        screenRules: {
          '/api/profile': 'ProfileScreen',
          '/api/orders/*/items': 'OrderDetailScreen',
        },
      ),
    );
    
  3. 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.

0
likes
0
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

Automatic network monitoring, screen-based API debugging, interactive JSON viewer, and in-app Debug Console for Flutter across Android, iOS, and Web.

Repository (GitHub)
View/report issues

Topics

#networking #debugging #inspector #dio #http

License

unknown (license)

Dependencies

dio, flutter, http

More

Packages that depend on flutter_auto_api_inspector