Skip to content
CAI
Software that uses CAICheck a score

trevorwang/retrofit.dart

65.9

Adequate · 19 September 2026

5.5k

lines of production code

Dart

with C++

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is a Dart code generation library that transforms annotated interfaces into HTTP client implementations using the Dio package. It supports multiple serialization strategies, including JSON, Protobuf, and custom mappers, while providing granular control over request configuration and response handling. The project includes comprehensive examples and tests demonstrating integration with Flutter, various data formats, and modern Dart SDK features.

How it got here

2019 — Retrofit v4 migration and generator refactor

8 changes.

This period focused on migrating the retrofit.dart library to version 4 by removing legacy HTTP annotations and refactoring the code generator to use a new RetrofitOptions system. The project upgraded core dependencies to support Dart 3.8+ and Dio 5.9, while updating example applications to demonstrate modern patterns such as explicit Dio injection and advanced type handling. Infrastructure improvements included establishing CI/CD pipelines, adding contributor automation, and expanding test coverage for the new generator configuration.

2020–2022 — Flutter integration and advanced API customization

5 changes.

This period focused on expanding the library's ecosystem by introducing a comprehensive Flutter example project and a DartJsonMapper serialization example, both accompanied by thorough integration tests. It also enhanced the core library with new annotations and adapters, enabling users to customize HTTP requests, handle responses with custom types, and configure per-request options.

2023–2025 — example expansion and test coverage

6 changes.

This period focused on expanding the library's documentation by adding comprehensive examples for relative base URLs, Protobuf serialization, and dart\_mappable integration. Concurrently, the team improved code quality and developer experience by adding unit tests for core components, implementing local coverage scripts, and enforcing commit message linting via Husky.

Features

Add Protobuf example demonstrating message serialization

The example\_protobuf directory now includes a complete example showing how to use Protobuf with the library. It provides proto definitions for Params and Result messages, along with the generated Dart code (.pb.dart, .pbjson.dart) and a RestClient interface that demonstrates sending and receiving Protobuf-encoded data via POST requests.

_example\protobuf · high confidence

Add dart\_mappable example demonstrating type conversion with Retrofit

The example\_dartmappable directory now provides a complete working example showing how to integrate the dart\_mappable library with Retrofit for automatic JSON serialization and type conversion. Users can see how to define models using @MappableClass(), configure the API client with Parser.DartMappable, and utilize generated mappers for encoding and decoding data, including support for optional parameters in error logging for backward compatibility.

_example\dartmappable · high confidence

Add example demonstrating relative base URL support

This change introduces a new example project (\example\_relative\_base\_url\) that demonstrates how to use the \@RestApi\ annotation with a relative base path (e.g., \baseUrl: 'tasks'\). The example includes the necessary configuration files (\analysis\_options.yaml\, \build.yaml\), a REST client definition (\TasksRestClient\) using the \dio\ package, data models (\Task\, \TaskGroup\, etc.), and a comprehensive test suite (\example\_test.dart\) that validates the client's behavior against a mock web server.

_example\_relative\_base\url · high confidence

Added Dartmapper example using DartJsonMapper parser

The example\_dartmapper/lib directory now includes a new example demonstrating the use of the DartJsonMapper parser for JSON serialization. This example defines an ApiService that uses the @RestApi annotation with parser: Parser.DartJsonMapper and includes a Task model annotated with @jsonSerializable. The example also shows how to initialize the reflectable code required by DartJsonMapper.

_example\dartmapper/lib · high confidence

Added Flutter example project scaffolding

Introduced a new Flutter example application (\flutter\_example\) that demonstrates the \retrofit\ library's integration with \dio\. The project includes platform-specific scaffolding for Android, iOS, and Linux, along with Dart code in \lib/example.dart\ that defines a \RestClient\ interface using \@RestApi\ and \@Header\ annotations, and a \MockAdapter\ for testing API calls locally.

_flutter\example · high confidence

Added local code coverage script for the retrofit package

A new shell script (retrofit/tool/coverage.sh) has been added to the project, allowing developers to locally generate code coverage reports for the retrofit package. The script automates the process of activating the coverage package, running tests with coverage collection enabled, and formatting the results into an lcov.info file.

retrofit/tool · high confidence

New annotations and adapters for custom response handling and request extras

The library now exposes new public APIs to customize HTTP requests and responses. Users can wrap API results in custom types (e.g., a Result pattern) using the new \CallAdapter\ interface and \@UseCallAdapter\ annotation. Request-level customization is enhanced with \@Extras\ for passing data to Dio interceptors, \@DioOptions\ for per-request configuration, and \@DioResponseType\ to control response parsing (JSON, stream, plain, bytes). Additionally, the \@RestApi\ annotation now supports \headers\ for global headers and \callAdapter\ for default adapters, while \ParseErrorLogger\ provides a base class for logging parsing errors.

retrofit/lib · high confidence

Project initialization and repository setup

The repository has been initialized with standard project infrastructure, including a MIT license, a Code of Conduct, and a Jekyll theme for documentation. CI/CD pipelines are configured via Travis CI and commit linting rules, while the README has been updated to reflect the current state of the retrofit.dart library, including usage examples, dependency specifications (retrofit ^4.9.0, retrofit\_generator ^10.0.1), and configuration options for the code generator.

(repo-wide) · high confidence

Removals

Removal of example application entry point

The main entry point for the example application (example/bin/main.dart) has been removed. This file previously initialized the RestClient and executed a sample API call to retrieve IP information, meaning the standalone example script is no longer available for direct execution.

example/bin · high confidence

Removal of legacy HTTP annotation classes

The \annotation/lib/http.dart\ file has been deleted, removing the legacy set of HTTP annotations including \RestApi\, \Method\ (and its subclasses \GET\, \POST\, \PATCH\, \PUT\, \DELETE\), \Headers\, \Header\, \Body\, \Field\, \Path\, \Query\, and \QueryMap\. Users relying on these specific annotation classes for defining API endpoints or request structures will need to migrate to the current annotation system provided in the library.

annotation/lib · high confidence

Behavioural changes

Added CI, coverage, and contributor generation tooling scripts

The repository now includes shell scripts to automate continuous integration and code quality workflows. A new Travis CI script (tool/travis.sh) manages multi-package builds by running dart analyze and other tasks across specified packages. A coverage script (tool/coverage.sh) automates the collection and formatting of Dart test coverage reports into lcov format. Additionally, a Python script (tool/gen\_contributors.py) was added to automatically update the project's contributor list using the all-contributors tool.

tool · high confidence

Enforced commit message linting via Husky

The project now enforces commit message standards by adding a Husky commit-msg hook that runs commitlint on every commit. This ensures that all commit messages adhere to the configured conventional commit format before they are accepted, improving consistency in the version history and changelog generation.

.husky · high confidence

Example app updated to modern Retrofit and Dio patterns

The example application has been refactored to demonstrate current best practices. The legacy \demo.dart\ and its generated code have been removed and replaced with a new \example.dart\ that uses the \@RestApi\ annotation with explicit \Dio\ injection and supports \ParseErrorLogger\. The new example showcases advanced features including nullable generic types (e.g., \ApiResult\<Task?\>\), extension types for query parameters, \Uint8List\ and \Stream\ return types, and runtime content-type handling via \@PartMap\. Additionally, a new \auth\_client.dart\ demonstrates authentication flows, and \api\_result.dart\ provides a generic wrapper for API responses.

example/lib · high confidence

Retrofit generator refactored to use new RetrofitOptions and updated annotation imports

The code generator entry point has been restructured: the old \builder.dart\ is removed and replaced by \retrofit\_generator.dart\, which now exposes a \retrofitBuilder\ that delegates to a new \generatorFactoryBuilder\. This factory introduces a \RetrofitOptions\ class to centralize build configuration (auto\_cast\_response, empty\_request\_body, class-name, use\_result, format\output) and applies \// dart format off/on\ comments when formatting is enabled. The generator now imports \retrofit\ annotations (e.g., \retrofit.RestApi\, \retrofit.Parser\) instead of the previous \http\ namespace, and generates implementation classes with the user-specified class name (or defaults to \\\<ClassName\>\) while preserving type parameters. Additionally, the generated code now includes explicit Dio, baseUrl, and error logger fields, and constructor generation respects non-default constructors from the annotated class.

generator/lib · high confidence

Test coverage

Added integration tests for the Dart mapper example; Added integration tests for the example REST client; Added tests for generator configuration and annotated code generation; Added unit tests for core Retrofit components.

Dependencies

Major dependency and SDK version upgrades across core packages and examples

The core \retrofit\ and \retrofit\_generator\ packages have been upgraded to require Dart SDK 3.8.0+ and 3.9.0+ respectively, with \retrofit\_generator\ now depending on \analyzer\ 13-15, \build\ 4, and \source\_gen\ 4. The \dio\ HTTP client dependency has been updated to version 5.9.0 in the core packages and examples. Several example projects (\example\_dartmappable\, \example\_dartmapper\, \example\_protobuf\, \example\_relative\_base\_url\, \flutter\_example\) have been added or updated to use Dart 3.3+ SDKs, \dio\ 5.7.0, and modern tooling like \build\_runner\ 2.4+ and \json\_serializable\ 6.8+. Additionally, the repository's CI tooling now includes \@commitlint/cli\ 20.1.0 and \husky\ 9.1.7 via a new \package.json\.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 66.

Lenses

  • Code Health 75
  • Architecture 97
  • Maturity 59
  • Readiness 78
  • Security 61
  • Domain Modelling 100

Changes since last survey

  • 300 commits — 204 feature/other, 96 fixes

By area

  • generator/lib — 83 commits
  • (root) — 48 commits
  • generator/CHANGELOG.md — 38 commits
  • .github/workflows — 26 commits
  • example/lib — 21 commits
  • retrofit/lib — 12 commits
  • generator/pubspec.yaml — 11 commits
  • generator/test — 8 commits
  • .circleci/config.yml — 6 commits
  • annotation/CHANGELOG.md — 6 commits
  • retrofit/CHANGELOG.md — 6 commits
  • example/pubspec.yaml — 4 commits
  • flutter_example/lib — 4 commits
  • example_dartmapper/lib — 3 commits
  • example_protobuf/lib — 3 commits
  • flutter_example/android — 3 commits
  • retrofit/analysis_options.yaml — 3 commits
  • retrofit/pubspec.yaml — 3 commits
  • annotation/lib — 2 commits
  • example_dartmappable/lib — 2 commits

Notable commits

  • fix: Add lean_builder dependency to fix package validation (#827)
  • fix: Document analyzer 9.x compatibility fix in CHANGELOG (#875)
  • fix: Fix #819 match fromJson parameter type in response body (#828)
  • fix: Fix @CancelRequest and @SendProgress code generation (#324)
  • fix: Fix @Part annotation generating wrong variable reference for MultipartFile (#824)
  • fix: Fix API break with dio 4.0.0-prev3 (#319)
  • fix: Fix DartMappable Record type support (#934)
  • fix: Fix Flutter Compute Generator to allow Multiple Functions for Generic Objects (#635)
  • fix: Fix List<dynamic> code generation to avoid incorrect Map casting (#811)
  • fix: Fix Map cast to preserve nullable value types (#850)
  • fix: Fix Map value deserialization for generic types with type parameters (#825)
  • fix: Fix bug deserialize List (#449)
  • fix: Fix code generation for methods with bare generic type parameters (#832)
  • fix: Fix dependencies for element2 (#775)
  • fix: Fix deprecated warning with analyzer 5.12.0 (#569)
  • fix: Fix deprecations of withNullability (#703)
  • fix: Fix documentation build workflow after doc folder has been moved by 3fcab1fadde64949f5fc10b4e2482248676acdde (#481)
  • fix: Fix duplicate null check for nullable optional File parameters in multipart requests (#813)
  • fix: Fix enum generation #696 and #663 (#697)
  • fix: Fix enum issue (#787)
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

trevorwang/retrofit.dart was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit d79e7e1e95968f0f0434a6cbdfed88d43296be40 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.