onResponse method

  1. @override
void onResponse(
  1. Response response,
  2. ResponseInterceptorHandler hdl
)

Called when the response is about to be resolved.

Implementation

@override
void onResponse(Response<dynamic> response, ResponseInterceptorHandler hdl) {
  if (!enabled) return hdl.next(response);
  final js = genByJson(response.data);
  final dt = DateTime.now();
  final tm = '${dt.hour}:'.padLeft(3, '0') +
      '${dt.minute}:'.padLeft(3, '0') +
      '${dt.second}:'.padLeft(3, '0') +
      '${dt.millisecond}'.padLeft(3, '0');
  logPrint([
    "RSP [$tm] : ${response.requestOptions.uri.path} <<<<<<<<<<<<<",
    if (responseHeader) "${response.headers}",
    js,
    if (rspExtra != null) "ERR-EXT ${rspExtra?.call(response)}",
    ''
  ].join(logLineBreak));
  return hdl.next(response);
}