Screen Overview
TheTaskScreen is the primary dashboard of the application where users can view and manage their teams. It serves as the home screen after successful authentication.
Location: lib/ui/screens/task_screen.dart
Purpose
The TaskScreen provides:- Display of all teams the current user belongs to
- User profile information in the app bar
- Navigation to team task details
- Team creation and deletion functionality
- Quick access to user-specific tasks and profile editing
State Management
State Variables
The currently authenticated Firebase user. Retrieved from
FirebaseAuth.instance.currentUser.List of teams that the current user is a member of. Each team contains:
id: Team document IDname: Team namemembers: List of member user IDscolor: Team color (as integer)userId: ID of the team creator
Loading state indicator. Initially
true, set to false after teams are fetched.Firebase Services
- FirebaseAuth (
_auth): Authentication service for current user management - FirebaseFirestore (
_firestore): Database operations for teams and users - FirebaseStorage (
_storage): Storage service for profile images - AuthService (
_authService): Custom authentication service wrapper - Logger (
_logger): Logging utility for debugging
Key Functionality
Initialization
On screen load (initState):
- Gets the current authenticated user
- Fetches teams where the user is a member
- Fetches the user’s profile image URL
Fetching Teams
task_screen.dart:38.
Deleting Teams
task_screen.dart:66.
Profile Image Management
profile_images/{userId}. Located at task_screen.dart:80.
User Interactions
App Bar Actions
- Profile Avatar (tap): Navigates to
EditProfileScreen - Tasks Icon (assignment icon): Navigates to
UserTasksScreenshowing user’s assigned tasks - Logout Icon: Signs out the user and returns to login screen
Team List Actions
View Team
Opens
AddTaskScreen with team details to view and manage tasksDelete Team
Shows confirmation dialog and deletes team (creator only)
Floating Action Button
Centered FAB that navigates toAddTeamScreen for creating new teams. Refreshes the team list when returning.
Widget Tree Structure
Components
Team Card
Each team is displayed as aCard with:
- Background color: Custom color from team data
- Title: Team name
- “Ver” button: Navigates to task management
- Delete button: Circular button with trash icon (only for creators)
User Greeting
The app bar displays:- Profile photo (or person icon if unavailable)
- “Hola, ” greeting
- “¡Bienvenido de nuevo!” welcome message
StreamBuilder (located at task_screen.dart:105).
Navigation Flow
Delete Confirmation Dialog
When deleting a team, users see a custom dialog with:- Large trash icon in a circular avatar
- Title: “¿Desea eliminar el equipo?”
- Warning: “Recuerda que el equipo eliminado, no se podrá recuperar.”
- Aceptar button (green background): Confirms deletion
- Cancelar button (gray background): Cancels operation
task_screen.dart:265-402.
Loading States
Code Structure
The screen follows Flutter’s StatefulWidget pattern:- TaskScreen (StatefulWidget): Widget definition
- TaskScreenState (State): State management and business logic
- Data fetching:
_fetchTeams(),_fetchTeamMembers() - Data operations:
_deleteTeam() - UI utilities:
getProfileImageUrl(),_fetchProfileImageUrl()