A powerful, easy-to-use API helper for Flutter that handles everything from simple GET requests to complex error handling, caching, and token management.
Package selection guidance compiled from public package information, community data, and project usage.
A comprehensive API helper for Flutter that simplifies HTTP requests with built-in support for GET, POST, and other methods. It handles error management, response caching, and token authentication seamlessly. Designed to reduce boilerplate code while improving reliability and performance in network operations across multiple platforms.
Use cases
Making REST API calls in Flutter apps
Implementing automatic retry logic on failed requests
Managing authentication tokens across requests
Caching API responses to reduce load time
Handling different HTTP status codes consistently
Key features
Built-in error handling and retry mechanisms
Support for request/response caching
Automatic token management and refresh
Simple, intuitive API interface
Cross-platform compatibility
Suitable for
Developers building apps with frequent API interactions
Teams prioritizing clean, maintainable network code
Projects requiring robust error recovery
Apps needing secure token handling
Flutter applications targeting multiple platforms
Considerations
May require additional setup for custom headers or complex authentication flows
Limited documentation beyond basic usage examples
Potential overhead if only simple requests are needed
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Flutter API Helper
🚀 A powerful, feature-rich HTTP client for Flutter applications
✅ Simple API - Intuitive methods for all HTTP operations
✅ Smart Caching - Memory and disk caching with configurable TTL
✅ Auto Retry - Exponential backoff for failed requests
✅ Token Management - Automatic token refresh and injection
✅ File Operations - Upload/download with progress tracking
✅ Network Aware - Built-in connectivity checking
✅ Widget Integration - Ready-to-use Flutter widgets
✅ Type Safe - Full generic type support
✅ Interceptors - Custom request/response processing
✅ Error Handling - Comprehensive error types and handling
🎯 Why Choose Flutter API Helper?
🆚 Comparison
Built-in HTTP
Flutter API Helper
Setup
Complex boilerplate
✨ One-line configuration
Caching
Manual implementation
🧠 Smart auto-caching
Retries
Custom retry logic
🔄 Exponential backoff
Errors
Generic exceptions
🛡️ Typed error handling
Files
Complex multipart
📁 Simple upload/download
Widgets
Custom FutureBuilder
🎯 Ready ApiBuilder
🚀 Quick Start
Installation
Add this to your package's pubspec.yaml file:
dependencies:flutter_api_helper:^1.0.0
Then run:
flutter pub get
⚡ 30-Second Setup
import'package:flutter_api_helper/flutter_api_helper.dart';
voidmain() {
// 🔧 Configure once, use everywhereApiHelper.configure(
ApiConfig(
baseUrl: 'https://api.yourapp.com',
enableLogging: true,
timeout: Duration(seconds: 30),
// 🧠 Smart caching out of the box
cacheConfig: CacheConfig(duration: Duration(minutes: 5)),
// 🔄 Auto-retry with exponential backoff
retryConfig: RetryConfig(maxRetries: 3),
),
);
runApp(MyApp());
}
📱 Usage Examples
🌐 Basic HTTP Operations
// GET request with automatic type castingfinal users = awaitApiHelper.get<List<User>>('/users');
// POST request with smart error handlingfinal newUser = awaitApiHelper.post('/users', data: {
'name': 'John Doe',
'email': 'john@example.com',
});
// PUT request with cachingfinal updatedUser = awaitApiHelper.put('/users/1',
data: {'name': 'Jane Doe'},
cache: CacheConfig(duration: Duration(minutes: 10)),
);
// DELETE request with retry logicawaitApiHelper.delete('/users/1',
retry: RetryConfig(maxRetries: 5),
);