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Γ§