An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          


Flutter News App Toolkit Logo

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.



coverage: XX%
Live Docs: View
Main Project: Browse

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.