pretty_chopper_logger 1.0.10 copy "pretty_chopper_logger: ^1.0.10" to clipboard
pretty_chopper_logger: ^1.0.10 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');
  }
}
copied to clipboard
5
likes
0
points
2.22k
downloads

Publisher

unverified uploader

Weekly Downloads

2024.06.09 - 2024.12.22

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

chopper, flutter, http

More

Packages that depend on pretty_chopper_logger