This repository provides a solution for handling Access Token expiration in Flutter apps by leveraging Refresh Tokens. The solution uses the Dio HTTP client and FlutterSecureStorage for secure token storage and management. The implementation ensures that users can continue their sessions without needing to log in again, even after the access token expires.
- Automatic Token Management: Automatically refreshes the access token when it expires.
- Secure Token Storage: Uses
FlutterSecureStorageto store tokens securely. - Interceptor Integration: Dio interceptors handle token injection and refresh seamlessly.
- Clean Architecture: Clear separation of concerns for better maintainability and scalability.
- Error Handling: Handles 401 Unauthorized errors by refreshing the token and retrying the request.
- Flutter 3.0 or higher
- Dio 5.0 or higher
- FlutterSecureStorage
- Add dependencies to your
pubspec.yamlfile:
dependencies:
dio: ^5.0.0
flutter_secure_storage: ^5.0.0