Retrofit & Dio Networking
SkillAI & modelsBuild type-safe HTTP networking with Dio and Retrofit including auth interceptors in Flutter. Use when integrating REST APIs with Dio or Retrofit.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Retrofit & Dio Networking skill
What this skill tells your AI
The instructions your AI receives, as published by hoangnguyen0403/agent-skills-standard in skills/flutter/flutter-retrofit-networking/SKILL.md and read by ahel’s review.
Priority: P0 (CRITICAL)
Structure
infrastructure/
├── data_sources/
│ ├── remote/ # Retrofit abstract classes
│ └── local/ # Cache/Storage
└── network/
├── dio_client.dart # Custom Dio setup
└── interceptors/ # Auth, Logging, Cache
Implementation Workflow
- Define Retrofit clients — Create abstract classes with
@RestApi()and HTTP annotations (@GET,@POST). Methods returnFuture<DTO>. - Create DTOs — Use
@freezedand@JsonSerializablefor all request/response bodies. - Map to domain — Data sources must map DTOs to Domain Entities (e.g.,
userDto.toDomain()). - Guard enums — Always use
@JsonKey(unknownEnumValue: Status.unknown)to prevent crashes from new backend values. - Add auth interceptor — Inject
Authorization: Bearer <token>inonRequest. - Handle token refresh — On 401, lock Dio, call
refreshToken(), update stored token, retry viadio.fetch(err.requestOptions). - Map failures — Convert
DioExceptionto typedFailureobjects (ServerFailure, NetworkFailure).
Retrofit Client & Safe Enum DTO Examples
See implementation examples for RestClient definitions and safe enum DTO patterns.
Anti-Patterns
- No Manual JSON Parsing: Use Retrofit's generated mappers instead of
jsonDecode - No Global Dio Instances: Inject
Diothrough DI - No Inline Try-Catch: repository layer should handle all Retrofit exceptions
- No Unguarded Enums: Always include
unknownEnumValueto prevent crashes on new backend values
Reference & Examples
For RestClient definitions and Auth Interceptor implementation: See references/REFERENCE.md.
Related Topics
feature-based-clean-architecture | error-handling
Signals
- GitHub stars
- 565
- Forks
- 164
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
flutter-retrofit-networking- Source
- github.com/hoangnguyen0403/agent-skills-standard