Skip to main content

chucker_flutter_plus 1.0.11 copy "chucker_flutter_plus: ^1.0.11" to clipboard
chucker_flutter_plus: ^1.0.11 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

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

Install #

flutter pub add chucker_flutter_plus

Capture requests #

Initialize the inspector and console logger once before runApp. Add its navigator observer 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: true,
  );

  final logger = NetworkLogger(
    config: const NetworkLogConfig(
      enableOnRelease: true,
      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 buffers each response before returning it so the inspector can save the response body, then returns the response bytes to the caller.

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 reads response bodies for inspection, and ChuckerHttpClient buffers the full response before returning it. This can increase memory use and response latency for large downloads or streaming endpoints. Media preview data is retained only up to 1 MiB; this storage limit does not limit the response delivered to your app.

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();

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. The tab shows the response content type and size. Video responses show a media card with their content type and size; inline video playback is not currently available. Media bodies up to 1 MiB are retained for previews. Larger media bodies are omitted from local history and marked as truncated, 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.

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: true,
    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. The defaults cover Authorization, Cookie, and Set-Cookie; configure additional headers with redactHeaders:

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

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
1
likes
0
points
639
downloads

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

unknown (license)

Dependencies

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

More

Packages that depend on chucker_flutter_plus