dio_curl_interceptor 4.1.0-beta copy "dio_curl_interceptor: ^4.1.0-beta" to clipboard
dio_curl_interceptor: ^4.1.0-beta copied to clipboard

A Dio interceptor that converts HTTP requests to cURL commands, with pluggable sinks, UI viewer, caching, and webhook integration.

example/example.dart

import 'package:dio/dio.dart';
import 'package:dio_curl_interceptor/dio_curl_interceptor.dart';
import 'package:flutter/foundation.dart';

void main() async {
  final dio = Dio();

  // Example 1: Minimal — relays through the NullSink (no extra output).
  dio.interceptors.add(
    DioCurlInterceptor(config: CurlConfig(sinks: [NullSink()])),
  );

  // Example 2: Configure logging + bodies with explicit sinks.
  dio.interceptors.add(
    DioCurlInterceptor(
      config: CurlConfig(
        sinks: [PrinterSink(printer: (text) => debugPrint('[Curl] $text'))],
      ),
    ),
  );

  // Example 3: Discord + Telegram webhooks + Hive cache + console printer.
  dio.interceptors.add(
    DioCurlInterceptor(
      config: CurlConfig(
        sinks: [
          DiscordSink(
            name: 'discord-alerts',
            webhookUrl: 'https://discord.com/api/webhooks/your-webhook-url',
          ),
          TelegramSink(
            name: 'telegram-alerts',
            botToken: 'YOUR_BOT_TOKEN',
            chatId: '-1003019608685',
          ),
          HiveSink(),
          PrinterSink(printer: print),
        ],
      ),
    ),
  );

  // Example 4: Manual, non-HTTP message via sendMessage.
  final interceptor = DioCurlInterceptor(
    config: CurlConfig(sinks: [NullSink()]),
  );
  await interceptor.sendMessage('App started');

  // Example 5: Disable dedupe for repeated events.
  dio.interceptors.add(
    DioCurlInterceptor(
      config: CurlConfig(
        relayOptions: const RelayOptions(dedupeTtl: Duration.zero),
        sinks: [PrinterSink(printer: print)],
      ),
    ),
  );
}
4
likes
160
points
918
downloads

Documentation

API reference

Publisher

verified publishervenhdev.me

Weekly Downloads

A Dio interceptor that converts HTTP requests to cURL commands, with pluggable sinks, UI viewer, caching, and webhook integration.

Repository (GitHub)
View/report issues

Topics

#curl #dio #logging #console #monitor

License

MIT (license)

Dependencies

colored_logger, crypto, dio, flutter, hive, hive_flutter, logging, path_provider, share_plus, type_caster

More

Packages that depend on dio_curl_interceptor