chopper 2.0.0 copy "chopper: ^2.0.0" to clipboard
chopper: ^2.0.0 copied to clipboard

outdated

Chopper is an http client generator using source_gen and inspired from retrofit

example/main.dart

import 'dart:async';

import 'package:chopper/chopper.dart';
import 'package:chopper/src/interceptor.dart';
import 'definition.dart';

main() async {
  final chopper = ChopperClient(
    baseUrl: "http://localhost:8000",
    services: [
      // the generated service
      MyService.create()
    ],
    converter: JsonConverter(),
  );

  final myService = chopper.service<MyService>(MyService);

  final response = await myService.getMapResource("1");
  print(response.body);

  final list = await myService.getListResources();
  print(list.body);

  chopper.dispose();
}

class _Converter implements Converter {
  @override
  FutureOr<Request> convertRequest(Request request) {
    // TODO: implement convertRequest
    return null;
  }

  @override
  FutureOr<Response<ConvertedResponseType>>
      convertResponse<ConvertedResponseType>(Response response) {
    // TODO: implement convertResponse
    return null;
  }
}
761
likes
0
pub points
98%
popularity

Publisher

verified publisherhadrienlejard.io

Chopper is an http client generator using source_gen and inspired from retrofit

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

http, logging, meta

More

Packages that depend on chopper