dio_shaker_interceptor 0.1.1
dio_shaker_interceptor: ^0.1.1 copied to clipboard
Shake to debug! dio_shaker_interceptor shows network request details. Inspect HTTP data easily with this Dio interceptor.
dio_shaker_interceptor #
The dio_shaker_interceptor package provides a Dio interceptor that allows you to easily inspect and debug network requests by shaking your device. It captures and displays detailed information about HTTP requests and responses, facilitating efficient development and troubleshooting.
Features #
- Capture and display detailed information about HTTP requests and responses.
- Shake your device to trigger the interceptor and view the network details.
- View request URL, method, headers, body, query parameters, status, and response.
- Easily integrate with your existing Dio setup.
Usage #
To use the dio_shaker_interceptor package, follow these steps:
-
Add Dependency:
Add the
dio_shaker_interceptorpackage to yourpubspec.yamlfile:dependencies: dio_shaker_interceptor: ^0.0.1 -
Import the Package:
Import the
dio_shaker_interceptorpackage in your Dart file:import 'package:dio_shaker_interceptor/dio_shaker_interceptor.dart'; -
Initialize Dio and Add Interceptor:
Create an instance of Dio and add the
DioShakerInterceptorto the interceptors list:import 'package:dio/dio.dart'; import 'package:dio_shaker_interceptor/dio_shaker_interceptor.dart'; void main() { final dio = Dio(); // Add the DioShakerInterceptor to the Dio instance dio.interceptors.add(DioShakerInterceptor()); } -
Integrate Shake Detection:
Integrate the
detectShakeAndOpenListCurlScreenfunction within thebuildmethod to enable the detection of the device's shake event and subsequently invoke the display of the cURL request list screen.Example 1 (Recommended) #
In this example, the
navigatorKeyis passed as a parameter, while thebuildContextis set tonull. This is the recommended approach.@override Widget build(BuildContext context) { ShakerDioDetect.detectShakeAndOpenListCurlScreen( buildContext: null, navigatorKey: navigatorKey, ); }Note: Ensure you have a global
navigatorKeydefined in your Flutter application.Example 2 (Alternative) #
In this example, the
buildContextis passed as a parameter, while thenavigatorKeyis set tonull.@override Widget build(BuildContext context) { ShakerDioDetect.detectShakeAndOpenListCurlScreen( buildContext: context, navigatorKey: null, ); }Note: This approach relies on the context being available at the time of the shake event.
-
Shake Device to Inspect Requests:
Shake your device to trigger the interceptor and view the network details. The interceptor will capture and display detailed information about HTTP requests and responses, including URL, method, headers, body, query parameters, status, and response.