dio_curl_interceptor 0.0.1 copy "dio_curl_interceptor: ^0.0.1" to clipboard
dio_curl_interceptor: ^0.0.1 copied to clipboard

A new Flutter package for logging curl with dio interceptor.

dio_curl_interceptor #

A Flutter package that provides a Dio interceptor for logging HTTP requests as cURL commands. This makes it easier to debug API calls and share them with others.

Features #

  • πŸ” Automatically converts Dio HTTP requests to cURL commands
  • πŸ“ Logs cURL commands to the console for easy debugging
  • βš™οΈ Configurable options for logging behavior
  • πŸ”„ Support for FormData conversion
  • 🎯 Minimal setup required

Getting started #

Add dio_curl_interceptor to your pubspec.yaml file:

dependencies:
  dio_curl_interceptor: ^0.0.1

Then run:

flutter pub get

Usage #

  1. First, import the package:
import 'package:dio_curl_interceptor/dio_curl_interceptor.dart';
  1. Add the interceptor to your Dio instance:
final dio = Dio();
dio.interceptors.add(CurlInterceptor());

Configuration Options #

You can customize the interceptor behavior with these options:

dio.interceptors.add(
  CurlInterceptor(
    printOnSuccess: true, // Only print cURL commands for successful requests
    convertFormData: true, // Convert FormData to JSON in cURL output
  ),
);

Example Output #

When making a POST request with JSON data:

final response = await dio.post(
  'https://api.example.com/data',
  data: {'name': 'John', 'age': 30},
);

The interceptor will log something like:

curl -i -X POST -H "Content-Type: application/json; charset=utf-8" -d "{\"name\":\"John\",\"age\":30}" "https://api.example.com/data"

Additional information #

  • Repository: GitHub
  • Bug Reports: Please file issues on the GitHub repository
  • Feature Requests: Feel free to suggest new features through GitHub issues

Contributions are welcome! Please feel free to submit a Pull Request.

2
likes
0
points
1.24k
downloads

Publisher

verified publishervenhdev.me

Weekly Downloads

A new Flutter package for logging curl with dio interceptor.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter

More

Packages that depend on dio_curl_interceptor