core/network — HTTP Networking

Create a configured Dio HTTP client with ordered interceptors and connectivity checks.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/Vantoan252003/Mozi --skill core-network-http-networking
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: core/network — HTTP Networking
Source: https://github.com/Vantoan252003/Mozi/tree/main/lib/core/network
Command: npx skills add https://github.com/Vantoan252003/Mozi --skill core-network-http-networking

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a consistent, production-ready HTTP networking foundation for Flutter apps so API calls are authenticated, reliable, and resilient to connectivity issues.

Core Features & Use Cases

  • ApiClientFactory: central factory to create a fully-configured Dio client with base options and ordered interceptors.
  • NetworkInfo: connectivity abstraction over connectivity_plus to check online status and stream connectivity changes.
  • Interceptors: Auth interceptor with token refresh queuing, Error interceptor mapping Dio errors to typed app exceptions, and conditional Logging interceptor for debug builds.
  • Use Case: Integrate into the DataSource layer to ensure all API calls include auth, handle 401 refresh flow safely, map network/server errors to app-level exceptions, and avoid requests when offline.

Quick Start

Initialize the network stack by calling ApiClientFactory.create with your baseUrl and a FlutterSecureStorage instance to obtain the Dio client for dependency injection.

Frequently Asked Questions about core/network — HTTP Networking

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle Dio 401 token refresh in Flutter without concurrent requests?

To handle Dio 401 token refresh safely, this Skill uses an Auth interceptor with queued token refresh logic, ensuring concurrent authenticated API requests wait for a single refresh cycle to complete before retrying.

How do I map HTTP network errors to app-level exceptions in Flutter?

You map HTTP network errors to app-level exceptions using a dedicated Error interceptor that catches Dio errors and converts them into typed app exceptions for reliable Flutter data layer handling.

What is the best way to check offline connectivity before making API requests in Flutter?

The best way to check offline connectivity is using a NetworkInfo abstraction over connectivity_plus, which checks online status and streams connectivity changes to prevent API requests when offline.

How do I set up a singleton Dio client with ordered interceptors in Flutter?

You set up a singleton Dio client using a central factory to create the instance with base options and ordered interceptors: Auth, then Error, then conditional Logging for debug builds.

Do I need FlutterSecureStorage to use this Dio HTTP networking setup?

Yes, you need FlutterSecureStorage because the network stack initialization requires passing a FlutterSecureStorage instance to the factory to securely manage tokens for authenticated API requests.

Why are my Flutter API calls failing when the network drops unexpectedly?

Flutter API calls fail on network drops without a connectivity guard; this Skill provides timeout handling and a NetworkInfo abstraction using connectivity_plus to observe connectivity changes and avoid offline requests.