Technical Documentation: Login Screen
Architecture


The Login Screen is implemented as a StatefulWidget in Flutter. It serves as the initial route of the application and coordinates with the AuthProvider to manage the authentication lifecycle.
Technical Details
- File Path: lib/screens/login_screen.dart
- State Management: Uses Provider pattern via AuthProvider.
- API Integration: Calls the /auth/login endpoint on the Go Backend.
- Security: Implements JWT-based authentication. Passwords are transmitted over secure channels and managed by the backend's Bcrypt hashing system.
Data Model
Login Request
Json{ "username": "user_string", "password": "password_string" }
Login Response
Json{ "token": "jwt_token_string", "user": { "id": 1, "username": "admin", "role": "admin" } }
Logic Flow
- Form Validation: The _handleLogin method validates that both fields are non-empty.
- Auth Call: Invokes authProvider.login(username, password).
- Redirection: On status code 200, uses Navigator.pushReplacement to navigate to the DashboardLayout.
- Error State: Catches specific HTTP errors (401 Unauthorized, 403 Forbidden) and updates the UI state to show descriptive error snackbars.