auth_logic library

A production-ready authentication package for Flutter.

MVVM architecture with Cubit state management. Supports login, register, forgot password, OTP verification, and more.

import 'package:auth_logic/auth_logic.dart';

final deps = AuthDependencies.create();
final authService = deps.authService;

Classes

ApiClient
AppCountryCodes
AppEndpoints
AppleLoginRequestModel
AuthDependencies
Factory for creating auth dependencies. Call AuthDependencies.create() to get pre-configured instances.
AuthService
Auth service handles all authentication API calls. Uses SecureTokenStorage for token persistence and ApiException for errors.
ChangePasswordRequestModel
CountryCode
DeviceHelper
Failure
FcmHelper
ForgetPasswordRequestModel
ForgetPasswordState
ForgetPasswordViewModel
GoogleLoginRequestModel
LoginRequestModel
LoginState
LoginViewModel
LogoutRequestModel
LogoutState
LogoutViewModel
NetworkFailure
PhoneNumberHelper
RegisterRequestModel
RegisterState
RegisterViewModel
ResendOtpRequestModel
ResendOtpState
ResendOtpViewModel
ResetPasswordRequestModel
ResetPasswordState
ResetPasswordViewModel
SecureTokenStorage
Abstract interface for secure token storage. Implement with flutter_secure_storage, hive, or any secure storage.
ServerFailure
SharedPrefsTokenStorage
SharedPreferences-based implementation of SecureTokenStorage. Replace with flutter_secure_storage for production.
TokenRefreshInterceptor
Interceptor that injects the access token into requests and attempts a token refresh on 401 responses.
UnknownFailure
UpdateProfileRequestModel
UserModel
VerifyOtpRequestModel
VerifyOtpState
VerifyOtpViewModel
VerifyRegistrationRequestModel
VerifyRegistrationState
VerifyRegistrationViewModel

Exceptions / Errors

ApiException