Milad-Akarie / pretty_dio_logger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use debugPrint

sebastianbuechler opened this issue · comments

I want to use the recommended debugPrint as logPrint option:
_dio.interceptors.add( PrettyDioLogger( logPrint: debugPrint ), )

However, I get an error that it is not valid because debugPrint is of the wrong type:
The argument type 'void Function(String?, {int? wrapWidth})' can't be assigned to the parameter type 'void Function(Object)'.dart(argument_type_not_assignable)

How is this intended to work?

I want to use the recommended debugPrint as logPrint option:
_dio.interceptors.add( PrettyDioLogger( logPrint: debugPrint ), )

However, I get an error that it is not valid because debugPrint is of the wrong type:
The argument type 'void Function(String?, {int? wrapWidth})' can't be assigned to the parameter type 'void Function(Object)'.dart(argument_type_not_assignable)

How is this intended to work?

  void appDebugPrint(Object message) {
      debugPrint(message.toString());
  }
  
  dio
      ..options.baseUrl = url
      ..interceptors.add(PrettyDioLogger(logPrint: appDebugPrint));
commented

I want to use the recommended debugPrint as logPrint option:
_dio.interceptors.add( PrettyDioLogger( logPrint: debugPrint ), )
However, I get an error that it is not valid because debugPrint is of the wrong type:
The argument type 'void Function(String?, {int? wrapWidth})' can't be assigned to the parameter type 'void Function(Object)'.dart(argument_type_not_assignable)
How is this intended to work?

  void appDebugPrint(Object message) {
      debugPrint(message.toString());
  }
  
  dio
      ..options.baseUrl = url
      ..interceptors.add(PrettyDioLogger(logPrint: appDebugPrint));

In one line:

	dio..interceptors.add(PrettyDioLogger(logPrint: (o) => debugPrint(o.toString())));