Skip to content

About

covert dio request to a cURL command line

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

curl_dio_logger_interceptor

Pub License: MIT

Language: English | 简体中文

Convert Dio requests into cURL commands for easy debugging.

Features

  • Prints the cURL equivalent of every request: method, URL, headers, query parameters, and body.
  • Optional response headers (-i), extra cURL flags, and a custom log sink.
  • Skips oversized parameters so long tokens or payloads do not flood the log.
  • Handles JSON, form-data, and multipart file bodies.

Requirements

  • Dart 2.18+ / Flutter 3.x
  • Dio 5.x

Get started

Install

Add curl_dio_logger_interceptor to your pubspec dependencies.

Super simple to use

import 'package:curl_dio_logger_interceptor/curl_dio_logger_interceptor.dart';

final dio = Dio();
dio.interceptors.add(CurlDioLoggerInterceptor(needResponseHeader: true));

Then you will get something like this

curl -X GET "https://httpbin.org/get?name=watson&foo=bar" -i --header "key1: value1" --header "key2: value2" --header "key3: value3"

Full parameter list

bool needResponseHeader;              // Print the server response HTTP headers.
bool printOnRequest = false;          // Print the command before the request starts.
bool ignoreLongParam = true;          // Skip parameters longer than the limit below.
int ignoreLongParamLength = 1024;
List<String>? extraParams = [];       // Extra curl flags, e.g. ['--insecure', '-L'].
void Function(Object object) logPrint; // Custom log sink.

Development

dart pub get
dart analyze
dart test

License

MIT — see LICENSE.

About

covert dio request to a cURL command line

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages