flutter_freedome_authentication
FreeDome authentication library for Flutter applications.
Features
- User authentication (login/logout)
- User registration
- Password management (change/reset)
- Token management (access/refresh tokens)
- Secure password hashing
- Persistent authentication state
Installation
Add this to your package's pubspec.yaml file:
dependencies:
flutter_freedome_authentication: ^1.0.0
Usage
Authentication Service
import 'package:flutter_freedome_authentication/flutter_freedome_authentication.dart';
final authService = FreeDomeAuthService(baseUrl: 'https://api.example.com');
// Login
final result = await authService.login(
username: '[email protected]',
password: 'password123',
);
if (result.success) {
print('Logged in as: ${result.user?.displayName}');
}
// Logout
await authService.logout();
Registration Service
final registrationService = FreeDomeRegistrationService(baseUrl: 'https://api.example.com');
// Register new user
final result = await registrationService.register(
RegistrationRequest(
username: 'newuser',
email: '[email protected]',
password: 'password123',
firstName: 'John',
lastName: 'Doe',
metadata: {},
),
);
Password Service
final passwordService = FreeDomePasswordService(baseUrl: 'https://api.example.com');
// Change password
await passwordService.changePassword(
currentPassword: 'oldpassword',
newPassword: 'newpassword',
accessToken: 'your_access_token',
);
// Request password reset
await passwordService.requestPasswordReset('[email protected]');
API Reference
Models
FreeDomeUser- User model with profile informationAuthResult- Authentication result with success/error statusRegistrationRequest- User registration dataPasswordChangeRequest- Password change dataPasswordResetRequest- Password reset data
Services
FreeDomeAuthService- Main authentication serviceFreeDomeRegistrationService- User registration serviceFreeDomePasswordService- Password management service
Events
UserLoggedInEvent- Fired when user logs inUserLoggedOutEvent- Fired when user logs outUserRegisteredEvent- Fired when user registersPasswordChangedEvent- Fired when password is changed
License
MIT License - see LICENSE file for details.