onRequest method

  1. @override
Future onRequest(
  1. RequestOptions options,
  2. RequestInterceptorHandler handler
)

Called when the request is about to be sent.

Implementation

@override
Future onRequest(
    RequestOptions options, RequestInterceptorHandler handler) async {
  CommonWidgets.logPrint('*** API Request - Start ***');

  printKV('URI', options.uri);
  printKV('METHOD', options.method);
  CommonWidgets.logPrint('HEADERS:');
  options.headers.forEach((key, v) => printKV(' - $key', v));
  CommonWidgets.logPrint('BODY:');

  printAll(options.data ?? '');

  CommonWidgets.logPrint('*** API Request - End ***');

  return handler.next(options);
}