Overview
TheRegisterScreen provides a complete user registration interface where new users can create an account with email/password authentication and set up their initial profile.
File: lib/ui/screens/register_screen.dart
Purpose
Handles new user registration flow including:- Email and password account creation
- Profile information collection (name, surname)
- Optional profile photo upload
- Profile data storage in Firestore
- Navigation to main app after successful registration
Key Components
State Variables
Instance of AuthService for authentication operations
Firestore instance for storing user profile data
Controls the name input field
Controls the surname input field
Controls the email input field
Controls the password input field
Controls the password confirmation field
Stores the selected profile image file
Form key for validation
Key Methods
_pickImage()
Allows users to select a profile photo from their device gallery._register()
Handles the registration process:- Validates form inputs
- Checks password confirmation match
- Creates Firebase Auth account
- Stores user profile in Firestore
- Navigates to TaskScreen on success
lib/ui/screens/register_screen.dart:37
Validation Methods
_validateEmail() Validates email format using regex pattern:lib/ui/screens/register_screen.dart:72
lib/ui/screens/register_screen.dart:83
UI Structure
Form Fields
- Profile Photo Picker - Optional circular avatar with camera icon
- Name Field - Required text input
- Surname Field - Required text input
- Email Field - Required with email validation
- Password Field - Required with minimum length validation
- Confirm Password Field - Must match password
Actions
- Register Button - Submits the registration form
- Back Button - Returns to login screen
Data Flow
Error Handling
- Password mismatch displays SnackBar message
- Email validation errors shown inline
- Registration failures handled by AuthService
- Form validation prevents submission with invalid data
Best Practices
- Form Validation: Use FormKey for centralized validation
- Password Security: Enforce minimum 8-character passwords
- User Feedback: Show clear error messages and success indicators
- Navigation: Use pushReplacement to prevent back navigation to registration
- Mounted Check: Always check if widget is mounted before navigation
Related Components
AuthService
Authentication service used for registration
LoginScreen
Login screen that links to registration
TaskScreen
Main dashboard after registration
Edit Profile
Profile editing after registration