Milad-Akarie / pretty_dio_logger

MIT License
238 stars 53 forks source link

How to use debugPrint #17

Closed sebastianbuechler closed 4 months ago

sebastianbuechler commented 3 years ago

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?

FelipeFernandesLeandro commented 3 years ago

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));
patevs commented 2 years ago

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())));