curl_logger_dio_interceptor 1.0.0 copy "curl_logger_dio_interceptor: ^1.0.0" to clipboard
curl_logger_dio_interceptor: ^1.0.0 copied to clipboard

Get your http requests printed as curl command in your terminal. Share them easily with your colleagues and import them in Postman!

example/lib/main.dart

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

void main() {
  runApp(MaterialApp(home: MyApp()));
}

class MyApp extends StatelessWidget {
  late final Dio _dio;

  MyApp({Key? key}) : super(key: key) {
    _dio = Dio();

    // avoid using it in production or do it at your own risks!
    if (!kReleaseMode) {
      _dio.interceptors.add(CurlLoggerDioInterceptor(printOnSuccess: true));
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Center(
      child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
        ElevatedButton(
          onPressed: () {
            _dio.post('https://flutter.dev/some404',
                options: Options(headers: {'Auth': 'SOME-TOKEN'}));
          },
          child: const Text('Run POST errored request'),
        ),
        const SizedBox(height: 20),
        const Text(
          'After pressing the button, go in your terminal and copy the curl code. Paste it in your terminal. Tada ✨',
          textAlign: TextAlign.center,
        )
      ]),
    ));
  }
}
25
likes
130
pub points
96%
popularity

Publisher

verified publisherownweb.fr

Get your http requests printed as curl command in your terminal. Share them easily with your colleagues and import them in Postman!

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dio

More

Packages that depend on curl_logger_dio_interceptor