dioLoggerInterceptor top-level property
InterceptorsWrapper
dioLoggerInterceptor
final
middleware
Implementation
final dioLoggerInterceptor =
InterceptorsWrapper(onRequest: (RequestOptions options, handler) {
debugPrint(
"┌------------------------------------------------------------------------------");
debugPrint('| [DIO] Request: ${options.method} ${options.uri}');
debugPrint('| ${options.data.toString()}');
debugPrint('| Headers:');
options.headers.forEach((key, value) {
debugPrint('|\t$key: $value');
});
debugPrint(
"├------------------------------------------------------------------------------");
handler.next(options); //continue
}, onResponse: (Response response, handler) async {
debugPrint(
"| [DIO] Response [code ${response.statusCode}]: ${response.data.toString()}");
debugPrint(
"└------------------------------------------------------------------------------");
handler.next(response);
// return response; // continue
}, onError: (DioError error, handler) async {
debugPrint("| [DIO] Error: ${error.error}: ${error.response.toString()}");
debugPrint(
"└------------------------------------------------------------------------------");
handler.next(error); //continue
});