---
# System prepended metadata

title: Chat Page - Marco

---

### Page Analysis for "Chats" Page

#### Name of the Page
Chats Page

#### Summary of the Page Contents / Function Purpose
The "Chats" page displays a list of chat conversations on the left panel and the detailed chat messages of a selected conversation on the right panel. Users can search through their chats, view chat details, and send messages.

#### Color Palette and Assets Needed
- **Primary Colors**:
  - ![#1D282F](https://via.placeholder.com/15/1D282F/1D282F) `#1D282F` (Dark gray background)
  - ![#2A3942](https://via.placeholder.com/15/2A3942/2A3942) `#2A3942` (Slightly lighter gray)
  - ![#06CF9C](https://via.placeholder.com/15/06CF9C/06CF9C) `#06CF9C` (Light blue)
  - ![#8696A0](https://via.placeholder.com/15/8696A0/8696A0) `#8696A0` (Gray text)
  - ![#FFFFFF](https://via.placeholder.com/15/FFFFFF/FFFFFF) `#FFFFFF` (White text)

- **Assets**:
  - User profile images
  - Icons for search, more options, and send

#### Widget Tree
```plaintext
Row
├── Container (Left Panel)
│   ├── Container (Search Bar)
│   ├── Expanded (Chat List)
│   │   └── ListView.builder
├── VerticalDivider
├── Expanded (Right Panel)
│   ├── Container (Chat Header)
│   ├── Expanded (Chat Messages)
│   │   └── ListView.builder
│   ├── Container (Message Input)
```

#### Step-by-Step Instructions on How to Build the Page

##### 1. Set Up Firestore Collections
- **Chats Collection**:
  - Fields: `chatId`, `userId`, `userName`, `userProfileImage`, `lastMessagePreview`, `timestamp`
- **Messages Collection**:
  - Fields: `messageId`, `chatId`, `senderId`, `messageText`, `messageMedia`, `timestamp`
- **Users Collection**:
  - Fields: `userId`, `userName`, `userProfileImage`, `status`

##### 2. Create the Main Structure
1. **Add a Row widget** to contain the left and right panels.
2. **Add a Container widget** for the left panel:
   - Set `width` to 300.
   - Set `color` to `Color(0xFF1D282F)`.

##### 3. Build the Left Panel
1. **Add a Container widget** for the search bar:
   - Set `padding` to `EdgeInsets.all(10)`.
   - Set `color` to `Color(0xFF2A3942)`.
   - Add a `TextField` widget inside the Container:
     - Set `decoration` with `hintText` as 'Search', `hintStyle` as `TextStyle(color: Color(0xFF8696A0).withOpacity(0.4))`, and `prefixIcon` as `Icon(Icons.search, color: Color(0xFF8696A0).withOpacity(0.4))`.
     - Set `style` to `TextStyle(color: Colors.white)`.

2. **Add an Expanded widget** to fill the remaining space with the chat list:
   - Inside the Expanded widget, add a `ListView.builder` to dynamically generate chat items from Firestore.

##### 4. Build the Chat List Items
1. **For each chat item** in `ListView.builder`:
   - Add a `ListTile` widget:
     - Set `leading` to `CircleAvatar` with `backgroundImage` from `chatItem['profileImageUrl']`.
     - Set `title` to `Text` with `chatItem['userName']`, styled with `TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500)`.
     - Set `subtitle` to `Text` with `chatItem['lastMessagePreview']`, styled with `TextStyle(color: Color(0xFF8696A0).withOpacity(0.6), fontSize: 14)`.
     - Set `trailing` to `Text` with `chatItem['timestamp']`, styled with `TextStyle(color: Color(0xFF8696A0).withOpacity(0.6), fontSize: 12)`.
     - Set `onTap` to navigate to the detailed chat view and pass the selected chat ID.

##### 5. Add a Vertical Divider
- **Add a `VerticalDivider` widget** between the left and right panels:
  - Set `color` to `Color(0xFF202C33)`.
  - Set `width` to 1.

##### 6. Build the Right Panel
1. **Add an Expanded widget** for the right panel:
   - Set `color` to `Color(0xFF121212)`.

2. **Add a Container widget** for the chat header:
   - Set `padding` to `EdgeInsets.all(10)`.
   - Set `color` to `Color(0xFF2A3942)`.
   - Inside the Container, add a `Row` widget to display user information and actions:
     - Add a `CircleAvatar` with `backgroundImage` from `selectedChatUserImageUrl`.
     - Add a `SizedBox` with `width` of 10.
     - Add a `Text` widget with 'John Isioma', styled with `TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold)`.
     - Add a `Spacer`.
     - Add an `IconButton` with `icon` as `Icon(Icons.more_vert, color: Colors.white)`.

3. **Add an Expanded widget** for the chat messages:
   - Inside the Expanded widget, add a `ListView.builder` to dynamically generate chat messages from Firestore.

##### 7. Build the Chat Messages
1. **For each message item** in `ListView.builder`:
   - Align the message based on the sender:
     - Use `Align` widget with `alignment` set to `Alignment.centerRight` for outgoing messages and `Alignment.centerLeft` for incoming messages.
   - Add a `Container` widget for the message bubble:
     - Set `padding` to `EdgeInsets.all(10)`.
     - Set `margin` to `EdgeInsets.only(bottom: 10)`.
     - Set `decoration` with `color` as `Color(0xFF06CF9C)` for outgoing messages and `Color(0xFF2A3942)` for incoming messages, and `borderRadius` to `BorderRadius.circular(10)`.
     - Add a `Text` widget inside the Container with the message text, styled with `TextStyle(color: Colors.white, fontSize: 14)`.

##### 8. Add the Message Input
1. **Add a Container widget** for the message input:
   - Set `padding` to `EdgeInsets.all(10)`.
   - Set `color` to `Color(0xFF2A3942)`.
   - Inside the Container, add a `Row` widget:
     - Add an Expanded widget with a `TextField` inside:
       - Set `decoration` with `hintText` as 'Type a message', `hintStyle` as `TextStyle(color: Color(0xFF8696A0).withOpacity(0.4))`, and `filled` as true with `fillColor` as `Color(0xFF1D282F)`.
       - Set `style` to `TextStyle(color: Colors.white)`.
     - Add a `SizedBox` with `width` of 10.
     - Add an `IconButton` with `icon` as `Icon(Icons.send, color: Color(0xFF06CF9C))`, and `onPressed` to send the message.

#### Full Page or View
- Full Page

#### Actions that can be performed
- Search for chats
- View chat details
- Send messages
- View more options in the chat header

#### Navigation details
- From the left panel, navigate to the right panel to view chat details.
- Navigate back to the chat list from the chat details view.

#### Firestore Schema Suggestions including dynamic data, queries, and necessary page variables
- **Chats Collection**: Store each chat with relevant user details and last message preview.
- **Messages Collection**: Store each message with sender details and text.
- **Users Collection**: Store user details.

##### Queries and Filters in FlutterFlow
1. **Fetch Chat List**:
   - Query the `Chats` collection to fetch chat items.
   - Use a Firestore query with ordering by `timestamp` to display the latest chats first.
   - Store the chat items in a local state variable for the `ListView.builder`.

2. **Fetch Chat Messages**:
   - Query the `Messages` collection with a filter on `chatId` to fetch messages for the selected chat.
   - Use a Firestore query with ordering by `timestamp` to display messages in chronological order.
   - Store the messages in a local state variable for the `ListView.builder`.

3. **Fetch User Details**:
   - Query the `Users` collection to fetch user details such as profile image and status.
   - Store the user details in a local state variable for display in the chat header and list.

4.

 **Dynamic Data Binding**:
   - Bind the dynamic data from Firestore queries to the corresponding widgets using FlutterFlow's data binding features.
   - Use state management to update the UI when data changes.

#### Local Data Filtering (if necessary)
- Implement search functionality to filter the chat list based on the user's input.
- Use a Firestore query with a `where` clause to filter chat items based on the search term.

#### Step-by-Step To-Do List to Build the Page
1. Set up Firestore collections and fields.
2. Create the main structure with a Row widget.
3. Build the left panel with a search bar and chat list.
4. Add a vertical divider between the panels.
5. Build the right panel with a chat header, chat messages, and message input.
6. Implement Firestore queries to fetch dynamic data.
7. Bind the dynamic data to the corresponding widgets.
8. Implement search functionality for the chat list.
9. Test the page on different screen sizes and devices to ensure responsiveness.

#### Estimated Complexity
- High: Due to dynamic data integration, responsive layout, and complex UI interactions.

By following these detailed instructions, you can build a responsive "Chats" page in FlutterFlow with dynamic data integration from Firestore, styled according to the provided color palette and design.

Based on the provided design details and color palette, here is the detailed layout for the "Chats" page in FlutterFlow. This layout will include padding, spacing, font sizes, colors, and other properties necessary for building the page.

### Detailed Layout for Chats Page

#### 1. Main Structure

```dart
Row(
  children: [
    // Left Panel
    Container(
      width: 300,
      color: Color(0xFF1D282F), // Dark gray background
      child: Column(
        children: [
          // Search Bar
          Container(
            padding: EdgeInsets.all(10),
            color: Color(0xFF2A3942), // Slightly lighter gray
            child: TextField(
              decoration: InputDecoration(
                hintText: 'Search',
                hintStyle: TextStyle(color: Color(0xFF8696A0).withOpacity(0.4)),
                prefixIcon: Icon(Icons.search, color: Color(0xFF8696A0).withOpacity(0.4)),
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(8),
                  borderSide: BorderSide.none,
                ),
                filled: true,
                fillColor: Color(0xFF1D282F),
              ),
              style: TextStyle(color: Colors.white),
            ),
          ),
          // Chat List
          Expanded(
            child: ListView.builder(
              itemCount: chatItems.length, // Replace with actual data
              itemBuilder: (context, index) {
                final chatItem = chatItems[index]; // Replace with actual data
                return ListTile(
                  leading: CircleAvatar(
                    backgroundImage: NetworkImage(chatItem['profileImageUrl']), // Dynamic user profile image
                  ),
                  title: Text(
                    chatItem['userName'], // Dynamic user name
                    style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
                  ),
                  subtitle: Text(
                    chatItem['lastMessagePreview'], // Dynamic last message preview
                    style: TextStyle(color: Color(0xFF8696A0).withOpacity(0.6), fontSize: 14),
                  ),
                  trailing: Text(
                    chatItem['timestamp'], // Dynamic timestamp
                    style: TextStyle(color: Color(0xFF8696A0).withOpacity(0.6), fontSize: 12),
                  ),
                  onTap: () {
                    // Navigate to the detailed chat view
                  },
                );
              },
            ),
          ),
        ],
      ),
    ),
    // Divider
    VerticalDivider(
      color: Color(0xFF202C33),
      width: 1,
    ),
    // Right Panel
    Expanded(
      child: Container(
        color: Color(0xFF121212), // Dark gray background
        child: Column(
          children: [
            // Chat Header
            Container(
              padding: EdgeInsets.all(10),
              color: Color(0xFF2A3942), // Slightly lighter gray
              child: Row(
                children: [
                  CircleAvatar(
                    backgroundImage: NetworkImage('selectedChatUserImageUrl'), // Dynamic user profile image
                  ),
                  SizedBox(width: 10),
                  Text(
                    'John Isioma', // Dynamic selected chat user name
                    style: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold),
                  ),
                  Spacer(),
                  IconButton(
                    icon: Icon(Icons.more_vert, color: Colors.white),
                    onPressed: () {
                      // More options
                    },
                  ),
                ],
              ),
            ),
            // Chat Messages
            Expanded(
              child: ListView.builder(
                padding: EdgeInsets.all(10),
                itemCount: messages.length, // Replace with actual data
                itemBuilder: (context, index) {
                  final message = messages[index]; // Replace with actual data
                  bool isMe = message['senderId'] == myUserId; // Dynamic sender check
                  return Align(
                    alignment: isMe ? Alignment.centerRight : Alignment.centerLeft,
                    child: Container(
                      padding: EdgeInsets.all(10),
                      margin: EdgeInsets.only(bottom: 10),
                      decoration: BoxDecoration(
                        color: isMe ? Color(0xFF06CF9C) : Color(0xFF2A3942), // Light blue for outgoing, dark gray for incoming
                        borderRadius: BorderRadius.circular(10),
                      ),
                      child: Text(
                        message['messageText'], // Dynamic message text
                        style: TextStyle(color: Colors.white, fontSize: 14),
                      ),
                    ),
                  );
                },
              ),
            ),
            // Message Input
            Container(
              padding: EdgeInsets.all(10),
              color: Color(0xFF2A3942), // Slightly lighter gray
              child: Row(
                children: [
                  Expanded(
                    child: TextField(
                      decoration: InputDecoration(
                        hintText: 'Type a message',
                        hintStyle: TextStyle(color: Color(0xFF8696A0).withOpacity(0.4)),
                        border: OutlineInputBorder(
                          borderRadius: BorderRadius.circular(8),
                          borderSide: BorderSide.none,
                        ),
                        filled: true,
                        fillColor: Color(0xFF1D282F),
                      ),
                      style: TextStyle(color: Colors.white),
                    ),
                  ),
                  SizedBox(width: 10),
                  IconButton(
                    icon: Icon(Icons.send, color: Color(0xFF06CF9C)),
                    onPressed: () {
                      // Send message
                    },
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    ),
  ],
);
```

### Responsive Layout Adjustments

- Use `MediaQuery` to adjust the width of the left panel and font sizes based on the screen size.
- Ensure the `ListView` for chat messages and chat list are scrollable.
- For mobile layouts, consider using a drawer for the left panel and a full screen for the right panel when a chat is selected.

### Firestore Data Integration

1. **Chats Collection**:
   - `chatId`: string
   - `userId`: string
   - `userName`: string
   - `userProfileImage`: string
   - `lastMessagePreview`: string
   - `timestamp`: timestamp

2. **Messages Collection**:
   - `messageId`: string
   - `chatId`: string
   - `senderId`: string
   - `messageText`: string
   - `messageMedia`: string
   - `timestamp`: timestamp

3. **Users Collection**:
   - `userId`: string
   - `userName`: string
   - `userProfileImage`: string
   - `status`: string

By following these detailed instructions, you can build a responsive chat page in FlutterFlow with dynamic data integration from Firestore, styled according to the provided color palette and design.