https://github.com/flutter-news-app-full-source-code/http-client
A robust and reusable Dart HTTP client built on top of the `dio` package, serving as a crucial abstraction layer within the Flutter News App Full Source Code Toolkit.
https://github.com/flutter-news-app-full-source-code/http-client
Last synced: 4 months ago
JSON representation
A robust and reusable Dart HTTP client built on top of the `dio` package, serving as a crucial abstraction layer within the Flutter News App Full Source Code Toolkit.
- Host: GitHub
- URL: https://github.com/flutter-news-app-full-source-code/http-client
- Owner: flutter-news-app-full-source-code
- License: other
- Created: 2025-04-24T13:35:48.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-02-02T18:57:47.000Z (4 months ago)
- Last Synced: 2026-02-08T08:55:30.558Z (4 months ago)
- Language: Dart
- Homepage:
- Size: 55.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
HTTP Client
A robust and reusable Dart HTTP client built on top of the `dio` package, serving as a crucial abstraction layer within the Flutter News App Full Source Code Toolkit.
This `http_client` package serves as the foundational HTTP client for the [**Flutter News App Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code). Built on top of the `dio` package, it simplifies API interactions by providing common HTTP methods, automatic authentication header injection, and mapping network/status code errors to specific custom exceptions. It ensures consistent and robust communication with backend services across the Flutter mobile app, web dashboard, and Dart Frog backend API.
## ⭐ Feature Showcase: Streamlined & Secure API Communication
This package provides a comprehensive set of features for managing HTTP requests.
🧱 Core Functionality
### 🚀 Robust `HttpClient`
- **`HttpClient` Class:** The main entry point for making HTTP requests, abstracting away `dio` complexities.
- **Simplified HTTP Methods:** Provides `get()`, `post()`, `put()`, and `delete()` methods for common API interactions.
### 🔐 Automatic Authentication
- **`AuthInterceptor`:** Automatically injects `Authorization: Bearer ` headers into requests.
- **Flexible `TokenProvider`:** Retrieves authentication tokens via a configurable asynchronous function, allowing integration with various authentication mechanisms.
### 🛡️ Standardized Error Handling
- **`ErrorInterceptor`:** Maps `DioException` types and non-2xx HTTP status codes to specific `HttpException` subtypes (e.g., `NetworkException`, `BadRequestException`, `UnauthorizedException`, `NotFoundException`, `ServerException`, `UnknownException`) defined in the `core` package. This ensures predictable and consistent error management across the application layers.
### ⚡ Performance & Control
- **Request Cancellation:** Supports request cancellation using `dio`'s `CancelToken` for improved resource management and user experience.
- **Configurable Timeouts:** Allows configuration of connection, receive, and send timeouts for robust network operations.
### 🌐 Platform Adaptability
- **`BrowserHttpClientAdapter` & `IOHttpClientAdapter`:** Automatically selects the appropriate HTTP client adapter for web and non-web platforms, ensuring seamless operation across different environments.
> **💡 Your Advantage:** You get a meticulously designed, production-quality HTTP client that simplifies API interactions, ensures secure authentication, provides robust error handling, and adapts to different platforms. This package accelerates development by providing a solid foundation for network communication.
## 🔑 Licensing
This source code is licensed for commercial use and is provided for local evaluation. A **Lifetime Commercial License** is required for any production or public-facing application.
Please visit the main [Flutter News App Full Source Code Toolkit](https://github.com/flutter-news-app-full-source-code) organization page to review the full license terms and to purchase.