A repository that provides an abstraction layer over authentication operations for the Flutter News App Toolkit.
This auth_repository
package contains the AuthRepository
class, which acts as an abstraction layer over an AuthClient
implementation (from the auth_client
package) within the Flutter News App Full Source Code Toolkit. Its primary purpose is to provide a clean, business-focused interface for authentication flows, ensuring standardized exception propagation, and handling authentication token persistence using KvStorageService
. This repository effectively decouples the application's core logic from the specifics of authentication mechanisms and token storage.
This package offers a comprehensive set of features for managing authentication operations.
🧱 Core Functionality
AuthRepository
: Provides a clean, business-focused interface for authentication-related tasks, abstracting the underlyingAuthClient
implementation.- Complete Authentication Lifecycle: Offers methods for a full authentication lifecycle, including
authStateChanges
(stream of user authentication state),getCurrentUser
(retrieves current user),requestSignInCode
(initiates email+code sign-in),verifySignInCode
(verifies code, saves token, returns user),signInAnonymously
(signs in anonymously, saves token, returns user), andsignOut
(signs out user, clears token).
KvStorageService
Integration: Manages authentication token persistence internally using an injectedKvStorageService
.- Direct Token Access: Exposes
saveAuthToken(String token)
,getAuthToken()
, andclearAuthToken()
for direct token manipulation, though these are typically handled by the main authentication flow methods.
- Exception Propagation: Propagates standardized
HttpException
s (fromcore
) from the underlying client andStorageException
s (fromkv_storage_service
), ensuring consistent and predictable error management across the application layers.
AuthClient
&KvStorageService
Dependencies: Requires instances ofAuthClient
(fromauth_client
) andKvStorageService
(fromkv_storage_service
) via its constructor, promoting loose coupling and testability.
💡 Your Advantage: This package provides a business-focused abstraction for authentication operations, simplifying the integration of user authentication into your application logic. It ensures consistent error handling, manages token persistence, and decouples your core application from specific authentication and storage implementations, enhancing maintainability and flexibility.
This auth_repository
package is an integral part of the Flutter News App Full Source Code Toolkit. For comprehensive details regarding licensing, including trial and commercial options for the entire toolkit, please refer to the main toolkit organization page.