Overview
TheAddTeamScreen provides an interface for creating new teams with customizable properties including name, description, color, and initial member selection.
File: lib/ui/screens/add_team_screen.dart
Purpose
Enables users to:- Create new teams with custom names and descriptions
- Select team colors for visual organization
- Search and add initial team members
- Automatically include the creator as a team member
Key Components
State Variables
Service for user search functionality
Service for team creation operations
List of users matching search query
Current search query for finding users
Name of the team being created
Description of the team/project
Selected color for the team (default: blue)
List of members selected to join the team
Key Methods
_searchUsers()
Searches for users by name or email:lib/ui/screens/add_team_screen.dart:28
_createTeam()
Creates the team with selected configuration:lib/ui/screens/add_team_screen.dart:42
_selectColor()
Updates the selected team color:lib/ui/screens/add_team_screen.dart:89
_addMemberToTeam()
Adds a user to the selected members list:lib/ui/screens/add_team_screen.dart:96
UI Structure
Team Configuration Section
- Team Name Input - Required text field for team name
- Project Description - Required text field for team description
- Color Picker - Visual color selection grid
Member Search Section
- Search Bar - TextField for searching users by name or email
- Search Results - ListView displaying matching users
- Selected Members - Chips showing currently selected members
Available Colors
Predefined color options:- Blue
- Green
- Red
- Orange
- Purple
- Pink
- Yellow
- Brown
Data Flow
Validation
Required Fields
- Team Name: Must not be empty
- Project Description: Must not be empty
Auto-corrections
- Current user automatically added to members list if not already included
- Prevents duplicate member additions
Team Data Structure
Teams are created with the following Firestore structure:Error Handling
- Empty field validation with SnackBar messages
- Team creation errors logged and displayed
- Network errors handled gracefully
- Mounted checks before navigation and UI updates
Best Practices
- Always Include Creator: Ensure the team creator is in the members list
- Validate Before Submit: Check all required fields
- Clear Search: Reset search results when query is empty
- User Feedback: Show loading indicators and error messages
- Return Status: Pass
trueback to caller on successful creation
Related Components
TeamService
Service handling team creation
AuthService
Service providing user search
TaskScreen
Main screen showing created teams
Team Management
Team management feature documentation