Flutter के लिए एक शक्तिशाली, आसान उपयोग करने वाला API हेल्पर जो सरल GET अनुरोध से लेकर जटिल त्रुटि प्रबंधन, कैशिंग और टोकन प्रबंधन तक सभी कार्यों को हैंडल करता है।
सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
फ्लटर के लिए एक व्यापक API सहायता, GET, POST और अन्य विधियों के लिए निर्मित समर्थन के साथ HTTP अनुरोधों को सरल बनाती है। यह त्रुटि प्रबंधन, प्रतिक्रिया कैशिंग और प्रमाणीकरण टोकन को बिना किसी झंझट के संभालती है। बहुप्लेटफॉर्म पर नेटवर्क ऑपरेशन में बॉयलरप्लेट कोड को कम करने और भरोसेमंदता और प्रदर्शन में सुधार करने के लिए डिज़ाइन किया गया है।
उपयोग
Flutter ऐप में REST API कॉल करना
असफल अनुरोधों पर स्वचालित पुनर्प्रयास तर्क कार्यान्वयन करना
अनुरोधों के माध्यम से प्रमाणीकरण टोकन का प्रबंधन करना
लोड समय कम करने के लिए API प्रतिक्रियाओं को कैश करें
विभिन्न HTTP स्थिति कोड को एक समान तरीके से संभालना
मुख्य विशेषताएँ
एम्बेडेड त्रुटि हैंडलिंग और रिट्राई मैकेनिज्म
अनुरोध/प्रतिक्रिया कैशिंग का समर्थन
स्वचालित टोकन प्रबंधन और रिफ्रेश
सरल, स्पष्ट एपीआई इंटरफेस
प्लेटफॉर्म के अनुकूलता
इनके लिए उपयुक्त
आवेदन बनाने वाले विकासकर्ता जो आवेदन अंतरक्रिया के साथ अक्सर API का उपयोग करते हैं
साफ, बनाए रखने योग्य नेटवर्क कोड प्राथमिकता देने वाली टीमें
मजबूत त्रुटि पुनर्स्थापना की आवश्यकता वाले प्रोजेक्ट
सुरक्षित τोकन प्रबंधन की आवश्यकता वाले ऐप्स
बहुप्लेटफॉर्म के लिए फ्लटर एप्लिकेशन
विचार योग्य बातें
कस्टम हेडर या जटिल प्रमाणीकरण प्रवाह के लिए अतिरिक्त सेटअप की आवश्यकता हो सकती है
मूल उपयोग उदाहरणों के अतिरिक्त सीमित दस्तावेज़न
अगर केवल सरल अनुरोध की आवश्यकता है, तो संभावित ओवरहेड हो सकता है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
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),
);