talira

retrofit.dart

Type-safe HTTP client generator for Dart, built for dio

open sourceMITfree

retrofit.dart generates type-safe REST clients for Dart and Flutter on top of the dio HTTP client. You declare an abstract API class with annotations such as @RestApi and @GET, and its generator, which runs with build_runner and uses source_gen, writes the implementation that sends the requests and converts the responses, with json_serializable as the default parser. It was inspired by Chopper and Square's Retrofit.

Problems it solves

  • generate a type-safe REST API client in Flutter
  • stop writing dio request boilerplate by hand in Dart
  • Retrofit-style HTTP client for Dart

Features

  • annotations such as @RestApi, @GET and @POST to declare an API
  • code generation with build_runner and source_gen
  • built on the dio HTTP client
  • pluggable response parsers, with json_serializable by default

Alternatives

The same job

These do what retrofit.dart does.

  1. Chopper A Retrofit-inspired HTTP client generator for Dart and Flutter
  2. http2 (Dart) HTTP/2 implementation for Dart, with a pooled, multiplexing http.Client
  3. dio HTTP client for Dart and Flutter with interceptors, FormData and cancellation
  4. dio_cache_interceptor HTTP cache interceptor for Dart's dio client, with pluggable stores

Compare retrofit.dart with the top 3