Skip to main content

chucker_flutter_plus 1.1.13 copy "chucker_flutter_plus: ^1.1.13" to clipboard
chucker_flutter_plus: ^1.1.13 copied to clipboard

In-app HTTP inspector for Flutter with request history, notifications, and shared logging for Dio, Chopper, and package:http.

Chucker Flutter Plus #

Chucker Flutter Plus feature banner

Pub Version Flutter Dart Platforms License: MIT Demo on YouTube

Dio Chopper package:http Hive CE

Capture and inspect HTTP traffic directly inside your Flutter app. Chucker Flutter Plus stores a bounded local request history, displays in-app banners, and can post optional system notifications. It supports Dio and package:http capture, plus a standalone console logger for Dio, Chopper, and package:http.


Features #

  • In-app HTTP inspector — Inspect request/response headers, bodies, status codes, sizes, and timings with ChuckerDioInterceptor and ChuckerHttpClient.
  • Notifications & banners — Foreground in-app banners and OS status-bar notifications with tap-to-open request details and host-managed notification mode.
  • Encrypted local history — Bounded Hive CE storage with optional 32-byte AES encryption.
  • Performance dashboard & diffing — Average/P95 latency, error rates, status ratios, host summaries, and side-by-side request comparison.
  • Media & speed test — Inline image and video response previews plus a built-in internet speed test screen.
  • Standalone console logger — Shared NetworkLogger for Dio, Chopper, and package:http with cURL generation and slow-request thresholds.
  • Privacy by default — Automatic redaction of sensitive headers, JSON keys, query parameters, multipart fields, and form fields before storage or logging.

Demo #

Watch the Chucker Flutter Plus demo

Watch the demo on YouTube Shorts


Table of contents #


Install #

flutter pub add chucker_flutter_plus

Capture requests #

Initialize the inspector and console logger once before runApp. Add ChuckerFlutterPlus.navigatorObserver to your MaterialApp so in-app banners can attach to the app overlay and notification taps can open the selected request.

import 'package:chucker_flutter_plus/chucker_flutter_plus.dart';
import 'package:chucker_flutter_plus/network_logger_dio.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await ChuckerFlutterPlus.initialize(
    enableNotifications: true,
    showInAppNotification: true,
    showStatusBarNotification: true,
    statusBarWhileForeground: false,
    inAppNotificationDuration: Duration(seconds: 3),
    inAppNotificationPosition: BannerPosition.top,
    notifyOnlyOnError: false,
    maximumEntries: 200,
    enableOnRelease: false,
  );

  final logger = NetworkLogger(
    config: const NetworkLogConfig(
      enableOnRelease: false,
      logRequestHeaders: true,
      logRequestBody: true,
      logResponseHeaders: true,
      logResponseBody: true,
      logErrorBody: true,
      logCurlCommand: true,
      maxBodyLength: 4000,
      slowRequestThreshold: Duration(seconds: 3),
    ),
    printer: debugPrint,
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) => MaterialApp(
    navigatorObservers: [ChuckerFlutterPlus.navigatorObserver],
    home: const HomePage(),
  );
}

final dio = Dio()
  ..interceptors.add(ChuckerDioInterceptor())
  ..interceptors.add(DioNetworkLoggerInterceptor(logger: logger));

For package:http, wrap a client:

import 'package:chucker_flutter_plus/chucker_flutter_plus.dart';
import 'package:http/http.dart' as http;

final client = ChuckerHttpClient(http.Client());
final response = await client.get(Uri.parse('https://example.com/items'));

ChuckerHttpClient returns the response stream immediately while forwarding each chunk to the caller. It retains at most 1 MiB for inspector capture; larger responses are marked truncated in history. Streamed downloads and SSE responses are not buffered before delivery.

Notifications when the host app owns initialization #

By default Chucker initializes flutter_local_notifications and receives its tap callbacks. That is convenient for a standalone setup, but the plugin has a single initialization callback: whichever code calls initialize() last owns notification taps. If the host already initializes the plugin, opt into host-managed mode so Chucker can display notifications without replacing the host callback:

final notifications = FlutterLocalNotificationsPlugin();
await notifications.initialize(
  const InitializationSettings(
    android: AndroidInitializationSettings('@mipmap/ic_launcher'),
    iOS: DarwinInitializationSettings(),
  ),
  onDidReceiveNotificationResponse: (response) {
    if (ChuckerFlutterPlus.handleNotificationPayload(response.payload)) return;
    handleAppNotification(response.payload);
  },
);

await ChuckerFlutterPlus.initialize(
  enableNotifications: true,
  hostManagedNotifications: true,
);

In host-managed mode the host initializes the plugin before Chucker, requests notification permissions, configures each target platform, and forwards tap payloads to handleNotificationPayload(). The host must also inspect launch details and forward the payload that opened the app, since Chucker does not replace or inspect the host's tap callback in this mode. Pass the same plugin instance if needed by your app; Chucker uses the package plugin singleton to show notifications. Initialize in this order: host plugin first, then Chucker.

The default mode remains available when Chucker owns notifications:

await ChuckerFlutterPlus.initialize(enableNotifications: true);

Warning

Do not initialize the plugin after Chucker in the default mode, or the host will replace Chucker's tap callback. Likewise, avoid initializing Chucker after the host in default mode, because Chucker would replace the host callback.

Platform support #

The inspector, local history, request capture, and console logger support Android, iOS, Linux, macOS, and Windows. The package requires Flutter 3.44 or later. It has no native implementation of its own; desktop support uses the Flutter and dependency plugins.

To enable desktop builds in an app, generate its runners from the app directory:

flutter create --platforms=linux,macos,windows .

Build each target on its supported host platform. Linux builds also require the GTK 3 development packages listed in Flutter's Linux setup guide.


HTTP compression #

Compression is negotiated by the HTTP client; Chucker does not compress requests or responses. With the default clients, gzip compression works across the native platforms:

Platforms Default behavior
Android, iOS, Linux, macOS, Windows Dio's native adapter and package:http's IOClient use Dart HttpClient, which requests gzip and decompresses gzip responses automatically.
Web Dio's browser adapter and package:http's BrowserClient leave negotiation and decompression to the browser. The browser controls Accept-Encoding.

No platform-specific Chucker setup is needed. Custom Dio adapters or custom package:http clients may use different compression behavior. Dart's native HttpClient automatically decompresses gzip; other encodings depend on the underlying client. See the Dart HttpClient compression docs, Dio adapters, and package:http client implementations.

When a response includes Content-Length, Chucker uses that value for the reported response size. For compressed responses this can be the smaller wire size, while the body exposed to the app has already been decompressed. If the length is absent, Chucker falls back to the observed body size.

Gzip usually saves network transfer for text and JSON, at the cost of CPU time to compress and decompress. It usually adds little benefit for already compressed formats such as JPEG, PNG, MP4, or ZIP. Chucker adds its own cost when capture is enabled: it observes response bodies and retains at most 1 MiB per response. This bounded copy does not limit the response delivered to your app. ChuckerHttpClient starts delivering streamed responses without waiting for the stream to finish.


Inspector tools #

Open the inspector #

Add the built-in button to a widget:

ChuckerFlutterPlus.button()

Or open the inspector directly. Pass a request ID to open that request's details page:

ChuckerFlutterPlus.showInspector(context);
ChuckerFlutterPlus.showInspector(context, requestId);

Use ChuckerFlutterPlus.hideInspector() to close it. The inspector also provides methods to clear history and export it as JSON:

await ChuckerFlutterPlus.clearLogs();
final json = await ChuckerFlutterPlus.exportLogs();

Encrypting local history #

Pass a 32-byte Hive AES key through initialize() or InspectorConfig:

await ChuckerFlutterPlus.initialize(encryptionKey: keyFromSecureStorage);

The request history, endpoint metrics, and request index boxes are encrypted with that key. Settings remain unencrypted and contain only inspector UI preferences. Keep the key in host secure storage; Chucker never persists or logs it.

Important

Existing unencrypted boxes cannot be opened as encrypted data: back up or clear them explicitly before enabling encryption. A wrong key fails to open the box and Chucker does not delete or reset data. Use the same key for the process lifetime; changing an already-open box key is rejected.

Performance dashboard #

Open the inspector menu and choose Performance dashboard to review the captured request history. The dashboard includes average and P95 latency, success and error rates, total response data, recent latency distribution, request volume over the last hour, status code ratios, and call counts by HTTP method and host. Host latency summaries highlight the slower services.

These statistics are calculated from the requests currently retained in local history. Response data totals use the captured response sizes, which may use a server-provided Content-Length where available.

Compare requests #

Choose Compare two requests in the inspector menu, then tap two captured requests. The comparison view places their URLs, methods, status, duration, transfer sizes, headers, and response bodies side by side. Different values are highlighted to make regressions and environment differences easier to spot.

Internet speed test #

Open a built-in screen to measure latency, download speed, and upload speed:

ChuckerFlutterPlus.showSpeedTest(context);

The default test endpoints use Cloudflare's public speed test service. You can pass your own compatible endpoints with downloadUrl, uploadUrl, and latencyUrl when your app uses a private test server.

Image and video responses #

Responses with an image/* or video/* content type get a Media tab. Images are previewable and can be opened larger by tapping the preview. Video responses play inline from their URL when the URL is directly accessible. Playback does not reuse captured authentication headers: those values are redacted before storage, and the video player does not attach request headers. Auth-protected or signed URLs with redacted query values may therefore fail to play. Media bodies up to 1 MiB are retained for previews. Larger media bodies are truncated in history while the recorded response size remains available.


Notifications #

In-app banners appear while the app is in the foreground. The setup above enables OS notifications for background requests and configures both delivery types. Set showStatusBarNotification to false to disable OS notifications.

On Android 13 and later, add the notification permission to the host app's android/app/src/main/AndroidManifest.xml; the package also requests runtime permission during initialization:

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Android notifications default to @mipmap/ic_launcher, which resolves the standard Flutter launcher icon under android/app/src/main/res/mipmap-*/ic_launcher.png. To use a custom icon, add a drawable resource under android/app/src/main/res/drawable/ (for example ic_notification.xml or .png) and pass its resource name without extension, or reference a mipmap resource with @mipmap/<name>:

await ChuckerFlutterPlus.initialize(
  enableNotifications: true,
  androidNotificationIcon: 'ic_notification',
);

You can also configure androidNotificationIcon on InspectorConfig. If the configured icon resource is missing on Android, initialization logs a warning and disables status bar notifications gracefully instead of throwing.

iOS and macOS use the app icon and request notification permission during initialization. Linux and Windows use their desktop notification services. Notification tap routing depends on the platform notification service and may not be available on every desktop environment.

Chucker notification payloads use the stable plain-text format chucker:<percent-encoded-request-id>. Chucker handles its own notification responses and opens the inspector on the matching request. If your app also handles local notification responses, check Chucker's payload before passing the payload to an app JSON decoder:

void handleNotificationTap(String? payload) {
  if (ChuckerFlutterPlus.handleNotificationPayload(payload)) return;
  if (payload == null) return;

  try {
    // Decode and handle this app's normal JSON notification payload.
    final data = jsonDecode(payload);
    handleAppNotification(data);
  } on FormatException {
    handleUnknownNotification(payload);
  }
}

The method returns false for payloads not created by Chucker. Chucker-prefixed payloads are consumed even if malformed, preventing them from reaching an app's JSON decoder. For custom request IDs, use ChuckerNotificationPayload.encode(requestId) and ChuckerNotificationPayload.tryParse(payload) to encode and safely recognize the format.


Console logging #

NetworkLogger is independent from inspector capture. Create one instance and share it across your network clients. Logging is enabled in debug builds by default. Use enableOnRelease: true to enable it in release builds, or forceLogging: true to override both the build mode and enabled: false.

import 'package:flutter/foundation.dart';
import 'package:chucker_flutter_plus/network_logger.dart';

final logger = NetworkLogger(
  config: const NetworkLogConfig(
    enableOnRelease: false,
    logRequestHeaders: true,
    logRequestBody: true,
    logResponseHeaders: true,
    logResponseBody: true,
    logErrorBody: true,
    logCurlCommand: true,
    maxBodyLength: 4000,
    slowRequestThreshold: Duration(seconds: 3),
  ),
  printer: debugPrint,
);

Use the matching adapter for each client:

import 'package:chopper/chopper.dart' as chopper;
import 'package:chucker_flutter_plus/dio_network_logger.dart';
import 'package:chucker_flutter_plus/chopper_network_logger.dart';
import 'package:chucker_flutter_plus/http_network_logger.dart';
import 'package:dio/dio.dart';
import 'package:http/http.dart' as http;

final dio = Dio()
  ..interceptors.add(DioNetworkLoggerInterceptor(logger: logger));

final chopper = ChopperClient(
  interceptors: [ChopperNetworkLoggerInterceptor(logger: logger)],
);

final loggedHttp = LoggingHttpClient(
  inner: http.Client(),
  logger: logger,
);

The console logger redacts common credential headers and sensitive JSON keys by default. Customize them with NetworkLogConfig.sensitiveHeaders, NetworkLogConfig.sensitiveJsonKeys, or a LogRedactor:

final logger = NetworkLogger(
  redactor: const LogRedactor(
    sensitiveHeaders: {'authorization', 'x-session-id'},
    sensitiveJsonKeys: {'password', 'access_token', 'private_note'},
  ),
);

Disable logging for an individual request with the adapter's control:

// Dio
dio.get('/private', options: Options(extra: {
  DioNetworkLoggerInterceptor.disableLoggingExtraKey: true,
}));

// Chopper
final privateChopperRequest = chopper.Request(
  'GET',
  Uri.parse('/private'),
  Uri.parse('https://api.example.com'),
  tag: const NetworkLoggerDisabled(),
);

// package:http: the control header is removed before sending.
final privateHttpRequest = http.Request('GET', uri)
  ..headers[LoggingHttpClient.disableLoggingHeader] = 'true';

LoggingHttpClient preserves response streaming and logs after the stream is read. It does not consume a StreamedRequest body to inspect it.


Privacy and retention #

Inspector capture is enabled in debug builds by default. Set enableOnRelease: true during initialization, or call ChuckerFlutterPlus.configure(enableOnRelease: true), to enable capture in release builds. Set maximumEntries and retention to bound local history.

Request headers are redacted before storage. Defaults include Authorization, Cookie, Set-Cookie, x-api-key, and api-key; configure additional headers with redactHeaders:

await ChuckerFlutterPlus.initialize(
  redactHeaders: {'authorization', 'cookie', 'x-api-key'},
);

Sensitive JSON keys, sensitive URL query parameters, multipart field values, and x-www-form-urlencoded request fields are redacted before storage. Customize the header and body rules and replacement marker at initialization:

await ChuckerFlutterPlus.initialize(
  redactHeaders: {'authorization', 'cookie', 'x-api-key', 'x-session-id'},
  redactBodyKeys: {
    'password', 'access_token', 'refresh_token', 'email', 'private_note',
  },
  redactionReplacement: '[hidden]',
);

InspectorConfig exposes the same redactHeaders, redactBodyKeys, and redactionReplacement options for configuration-object setup. Key matching is case and punctuation insensitive, including nested JSON objects and lists. Unstructured non-JSON text bodies are kept as captured because their structure cannot be reliably inspected. Multipart file bytes are not interpreted as text; field values are redacted in the stored preview.

Note

Request and response bodies are stored for inspection. Review the data your app sends before enabling capture or console logging in production.


Development #

dart format .
flutter analyze
flutter test

License #

MIT License — see LICENSE for details.

1
likes
160
points
448
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

In-app HTTP inspector for Flutter with request history, notifications, and shared logging for Dio, Chopper, and package:http.

Repository (GitHub)
View/report issues

Topics

#flutter #http #network #inspector #logging

License

MIT (license)

Dependencies

chopper, dio, flutter, flutter_local_notifications, hive_ce, hive_ce_flutter, http, material_ui, path_provider, share_plus, video_player

More

Packages that depend on chucker_flutter_plus