Sweet Fetch
Sweet Fetch is a Dio-based HTTP client manager that allows you to easily configure token refresh, error handling, and custom HTTP settings. It is designed to provide a clean and efficient API client layer for Flutter and Dart projects.
🚀 Features
• 🔐 Token-based authentication (OAuth2 support)
• 🔄 Automatic token refresh (refresh token support)
• 🧠 Smart error interception and redirection
• 📦 Custom HttpClientManager built on Dio
• 🧰 Hive-powered TokenStorage
• 🧪 Test-friendly architecture
Usage
final sweetFetch = SweetFetch();
await sweetFetch.init(
options: BaseOptions(baseUrl: 'https://api.example.com'),
refreshTokenConfig: RefreshTokenConfig(
refreshUrl: 'https://api.example.com/token/refresh',
refreshQueryParameters: {
'client_id': 'your-client-id',
'client_secret': 'your-client-secret',
},
refreshData: {
'refresh_token': 'your-refresh-token',
},
),
);
final response = await sweetFetch.dioClient.get('/user/profile');
Additional information
• Token refresh operations are compatible with fresh_dio.
• Tokens are stored locally using Hive.
🤝 Contributing
Contributions are welcome! Please open an issue before submitting a pull request.
License
MIT License © Mert Erkoç