Skip to main content

flutter_auto_api_inspector 1.1.1 copy "flutter_auto_api_inspector: ^1.1.1" to clipboard
flutter_auto_api_inspector: ^1.1.1 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, pure Dart/Flutter network debugging toolkit that automatically monitors API requests, groups them by the Flutter screen that triggered them, masks sensitive credentials, prints structured Debug Console logs, and provides a responsive In-App API Inspector + Debug Console across Android, iOS, and Web.


Key Features #

  • Screen-Wise API Grouping: Automatically tracks Flutter navigation via ApiInspector.navigatorObserver (and supports 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.
  • Multi-Client Interception:
    • Mode A (Dio): ApiInspector.attachDio(dio)
    • Mode B (package:http): ApiInspector.attachHttp(http.Client())
    • 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:
    • Structured, readable logs directly in VS Code / Android Studio Debug Console.
    • Built-in Console Tab inside the In-App Inspector displaying live API logs, screen transitions, debugPrint(), print() (via runWithConsoleCapture), and FlutterError exceptions — even on standalone QA/Staging devices without a laptop!
  • Interactive JSON Tree Viewer:
    • Pretty-printed collapsible/expandable objects and arrays.
    • Live search across JSON keys and values with match counter and highlights.
    • Switch between Tree and Raw views, plus one-tap Copy JSON and Copy cURL.
  • Error Categorization & Performance Analytics:
    • Distinguishes HTTP non-2xx errors (400, 401, 403, 404, 422, 429, 5xx) from transport exceptions (Connection/Receive/Send Timeout, DNS Failure, SSL/TLS, Network Unavailable, Cancelled).
    • Dashboard KPIs: Total, Success, Failed, Pending, Slow calls, Average & P95 duration, and per-screen health.
  • Security-First & Performance-Safe:
    • Disabled automatically in release builds (enabled: kDebugMode).
    • Automatic masking for sensitive headers (Authorization, Cookie, Set-Cookie, X-Api-Key) and nested JSON keys (password, token, access_token, refresh_token, etc.) in memory, console logs, cURL, and JSON exports.
    • Bounded in-memory FIFO storage (default 500 requests) and configurable body capture limit (default 1 MB).
    • Zero disk persistence and zero remote uploads.

Quick Start #

1. Install #

flutter pub add flutter_auto_api_inspector

2. Initialize once in main() #

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: true, // Defaults to kDebugMode
      showConsoleLogs: true,
      captureAppConsoleLogs: true,
      enableScreenTracking: true,
      enableDashboard: true,
      showFloatingButton: true,
      maxRequests: 500,
      slowRequestThreshold: Duration(milliseconds: 1000),
    ),
  );

  // Optional: capture standard print() calls inside the In-App Console tab too
  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'),
      // or: Options(extra: {'inspector_screen': '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 (app stays interactive!) + full-screen on mobile web. Browser CORS rules still apply normally.

License #

MIT License — 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