pretty_chopper_logger 1.2.1 copy "pretty_chopper_logger: ^1.2.1" to clipboard
pretty_chopper_logger: ^1.2.1 copied to clipboard

Pretty Chopper logger is a Chopper interceptor that logs network calls in a pretty, easy to read format.

example/main.dart

import 'dart:developer';

import 'package:chopper/chopper.dart';
import 'package:pretty_chopper_logger/pretty_chopper_logger.dart';

import 'sample_service.dart';

void main() async {
  final chopper = ChopperClient(
    baseUrl: Uri.parse("http://www.mocky.io/"),
    interceptors: [PrettyChopperLogger()],
    services: [
      // Create and pass an instance of the generated service to the client
      SampleService.create()
    ],
  );

  /// Get a reference to the client-bound service instance...
  final sampleService = chopper.getService<SampleService>();

  /// Making a request is as easy as calling a function of the service.
  final response = await sampleService.getMockResponse();

  if (response.isSuccessful) {
    // Successful request
    final body = response.body;
    log(body);
  } else {
    // Error code received from server
    final code = response.statusCode;
    final error = response.error;
    log('Status:$code, Error:$error');
  }
}
5
likes
160
points
2.06k
downloads

Publisher

unverified uploader

Weekly Downloads

Pretty Chopper logger is a Chopper interceptor that logs network calls in a pretty, easy to read format.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

chopper, flutter, http

More

Packages that depend on pretty_chopper_logger