Yt constructor Null safety

Yt(
  1. {LogOptions logOptions = const LogOptions(LogLevel.error, stackTraceLevel: LogLevel.off),
  2. LoggyPrinter printer = const PrettyPrinter(showColors: false)}
)

Implementation

Yt(
    {LogOptions logOptions = const LogOptions(
      LogLevel.error,
      stackTraceLevel: LogLevel.off,
    ),
    LoggyPrinter printer = const PrettyPrinter(
      showColors: false,
    )}) {
  Loggy.initLoggy(logPrinter: printer, logOptions: logOptions);

  (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
      (client) => httpClient;

  dio.interceptors.add(InterceptorsWrapper(
      onRequest: (RequestOptions options, RequestInterceptorHandler handler) {
    loggy.debug('URI: ${options.uri}');

    loggy.debug('HEADERS:\n${options.headers}');

    loggy.debug('REQUEST:\n${options.data}');

    return handler.next(options); //continue
  }, onResponse: (response, handler) {
    loggy.debug('RESPONSE:\n${response.data}');

    return handler.next(response); // continue
  }, onError: (DioError e, handler) {
    loggy.error('ERROR:\n$e');

    return handler.next(e); //continue
  }));
}