dio_intercept_to_curl 0.2.0 copy "dio_intercept_to_curl: ^0.2.0" to clipboard
dio_intercept_to_curl: ^0.2.0 copied to clipboard

Intercept Dio requests and print them as curl commands in the debug panel. Easily paste the request in your terminal to run it again. Use it to easily debug your Dio request.

example/lib/main.dart

import 'package:dio_intercept_to_curl/dio_intercept_to_curl.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(DioInterceptToCurl(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,
          )
        ]
      )
    ));
  }
}
8
likes
160
pub points
89%
popularity

Publisher

verified publisherblackflamedigital.com

Intercept Dio requests and print them as curl commands in the debug panel. Easily paste the request in your terminal to run it again. Use it to easily debug your Dio request.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter

More

Packages that depend on dio_intercept_to_curl