Agent-skills-standard flutter-retrofit-networking
Build type-safe HTTP networking with Dio and Retrofit including auth interceptors. Use when integrating Dio, Retrofit, or API auth interceptors in Flutter. (triggers: **/data_sources/**, **/api/**, Retrofit, Dio, RestClient, GET, POST, Interceptor, refreshing)
install
source · Clone the upstream repo
git clone https://github.com/HoangNguyen0403/agent-skills-standard
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/HoangNguyen0403/agent-skills-standard "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/flutter/flutter-retrofit-networking" ~/.claude/skills/hoangnguyen0403-agent-skills-standard-flutter-retrofit-networking && rm -rf "$T"
manifest:
skills/flutter/flutter-retrofit-networking/SKILL.mdsource content
Retrofit & Dio Networking
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
and HTTP annotations (@RestApi()
,@GET
). Methods return@POST
.Future<DTO> - Create DTOs — Use
and@freezed
for all request/response bodies.@JsonSerializable - Map to domain — Data sources must map DTOs to Domain Entities (e.g.,
).userDto.toDomain() - Guard enums — Always use
to prevent crashes from new backend values.@JsonKey(unknownEnumValue: Status.unknown) - Add auth interceptor — Inject
inAuthorization: Bearer <token>
.onRequest - Handle token refresh — On 401, lock Dio, call
, update stored token, retry viarefreshToken()
.dio.fetch(err.requestOptions) - Map failures — Convert
to typedDioException
objects (ServerFailure, NetworkFailure).Failure
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
through DIDio - No Inline Try-Catch: repository layer should handle all Retrofit exceptions
- No Unguarded Enums: Always include
to prevent crashes on new backend valuesunknownEnumValue
Reference & Examples
For RestClient definitions and Auth Interceptor implementation: See references/REFERENCE.md.
Related Topics
feature-based-clean-architecture | error-handling