Dio Requests Inspector
A HTTP inspector for Dio, which can intercept and log HTTP requests and responses.
Features
XIntercept and log HTTP requests and responsesXSecure HTTP requests with passwordsXFilter logs by request time, method, and statusXSearch logs by pathXEasily share request and response dataXBeautify JSON dataXImage support for responsesXResponse body searchingXSummary flag supportXCopy to cURLXBeautiful user interface
How to use
- Add the package with command
flutter pub add dio_request_inspector
- Create and configure
DioRequestInspectorinstance
final DioRequestInspector inspector = DioRequestInspector(
isInspectorEnabled: true,
password: '123456', // optional, remove if you don't need password
showSummary: true, // optional, default is true
);
- add interceptor to your Dio instance
dio.interceptors.add(inspector.getDioRequestInterceptor());
- Wrap your
myAppwithDioRequestInspectorMain
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(
DioRequestInspectorMain(
inspector: inspector,
child: const MyApp(),
),
);
}
- add
navigatorObserversto yourMaterialApp
navigatorObservers: [
DioRequestInspector.navigatorObserver,
],
Usage
Show Inspector UI
You can open the DioRequestInspector in two ways:
-
Long press on your screen to show DioRequestInspector UI (if using
DioRequestInspectorMain) -
Programmatically call:
inspector.goToInspector();
Parameters
isInspectorEnabled- Enable or disable the inspector (required)password- Optional password protection for the inspectorshowSummary- Show summary view (default: true)
Example
See the example directory for a complete working example.