Files
retail/lib/core/providers/core_providers.dart
2025-10-21 16:30:11 +07:00

26 lines
886 B
Dart

import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../network/dio_client.dart';
import '../storage/secure_storage.dart';
part 'core_providers.g.dart';
/// Provider for DioClient (singleton)
///
/// This is the global HTTP client used across the entire app.
/// It's configured with interceptors, timeout settings, auth token injection,
/// and automatic token refresh on 401 errors.
@Riverpod(keepAlive: true)
DioClient dioClient(Ref ref) {
final storage = ref.watch(secureStorageProvider);
return DioClient(secureStorage: storage);
}
/// Provider for SecureStorage (singleton)
///
/// This is the global secure storage used for storing sensitive data like tokens.
/// Uses platform-specific secure storage (Keychain on iOS, EncryptedSharedPreferences on Android).
@Riverpod(keepAlive: true)
SecureStorage secureStorage(Ref ref) {
return SecureStorage();
}