Overview
TheUserTaskScreen displays all tasks assigned to a specific user, with the ability to filter tasks by status and update the user’s display name.
File: lib/ui/screens/user_task_screen.dart
Purpose
Provides a personalized task view where users can:- View all tasks assigned to them across all teams
- Filter tasks by status (No Iniciado, En desarrollo, Finalizado)
- Update their display name
- See task details and progress
Constructor
The unique identifier of the user whose tasks to display
Key Components
State Variables
Display name of the current user
Email address of the current user
Currently selected status filter (default: “No Iniciado”)
Key Methods
initState()
Initializes user information from Firebase Auth:lib/ui/screens/user_task_screen.dart:20
updateUserName()
Updates the user’s display name in Firebase Auth:lib/ui/screens/user_task_screen.dart:27
showUpdateNameDialog()
Displays a dialog for updating the user’s name:lib/ui/screens/user_task_screen.dart:43
UI Structure
AppBar
- Title: “Mis Tareas” (My Tasks)
- Back Button: Returns to previous screen
- Edit Name Action: IconButton to show name update dialog
Status Filter
Chip-based filter buttons:- No Iniciado (Not Started) - Red chip
- En desarrollo (In Progress) - Orange chip
- Finalizado (Completed) - Green chip
Task List
StreamBuilder displaying filtered tasks:- Shows tasks assigned to the user with selected status
- Real-time updates via Firestore snapshots
- Empty state message when no tasks match filter
Firestore Query
Tasks are queried with compound filters:Query Conditions
- responsibleId: Matches the provided userId parameter
- status: Matches the currently selected status filter
Task Status Values
Task has not been started yet (red indicator)
Task is currently in progress (orange indicator)
Task has been completed (green indicator)
Data Flow
Task Display
Each task ListTile shows:- Title: Task name
- Subtitle: Task description
- Status Icon: Visual indicator based on status
- Red pending icon for “No Iniciado”
- Orange clock for “En desarrollo”
- Green check for “Finalizado”
Navigation
Accessed from:- TaskScreen AppBar action button (assignment icon)
- Shows tasks for the current logged-in user
Best Practices
- Use Streams: Real-time updates via StreamBuilder
- Index Queries: Ensure Firestore has composite index for userId + status
- Handle Empty States: Show meaningful message when no tasks
- Validate Name: Check non-empty before updating display name
- User Feedback: Show SnackBar confirmations for actions
Performance Considerations
Firestore Indexing
Required composite index:Query Efficiency
- Filters applied at database level
- Only matching documents returned
- Real-time listener updates automatically
- Consider pagination for large task lists
Error Handling
- User Not Found: Falls back to default names
- Stream Errors: Handled by StreamBuilder
- Update Failures: Display error SnackBar
- Empty Name: Validate before updating
Related Components
TaskScreen
Main dashboard linking to user tasks
Task Management
Task management feature overview
AddTaskScreen
Screen for creating and editing tasks
User Profiles
User profile management