✅ 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),
);