> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-platform-docs-release.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# One-to-One / Group Chat

> Build a focused one-to-one or group chat experience in Flutter with CometChat UI Kit.

<Accordion title="AI Agent Component Spec">
  | Field        | Value                                                                          |
  | ------------ | ------------------------------------------------------------------------------ |
  | Package      | `cometchat_chat_uikit`                                                         |
  | Framework    | Flutter                                                                        |
  | Components   | `CometChatMessageHeader`, `CometChatMessageList`, `CometChatMessageComposer`   |
  | Layout       | Single chat window — no conversation list                                      |
  | Prerequisite | Complete [Getting Started](/ui-kit/flutter/v5/getting-started) Steps 1–4 first |
  | Pattern      | Support chat, embedded widgets, focused messaging                              |
</Accordion>

This guide builds a single chat window — no conversation list. Users go directly into a one-to-one or group chat. Good for support chat, deep links, or focused messaging.

This assumes you've already completed [Getting Started](/ui-kit/flutter/v5/getting-started) (project created, UI Kit installed, init + login working).

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-platform-docs-release/v8sMFo4IEqcgs2_F/images/c401197a-chat_experience_one_on_one-5b74b8c178c83ecb0a8879e898fcb854.png?fit=max&auto=format&n=v8sMFo4IEqcgs2_F&q=85&s=1905a34d02a60f6bde90eeff302a16fe" width="1440" height="833" data-path="images/c401197a-chat_experience_one_on_one-5b74b8c178c83ecb0a8879e898fcb854.png" />
</Frame>

[View Sample App on GitHub](https://github.com/cometchat/cometchat-uikit-flutter/tree/v5/sample_app)

***

## What You're Building

Three components stacked vertically:

1. **Chat header** — displays recipient name, avatar, and call buttons
2. **Message list** — real-time chat history
3. **Message composer** — text input with media and emojis

***

## Step 1 — Create the Chat Screen

The app fetches a user on mount and renders the message components.

```dart title="lib/chat_screen.dart" theme={null}
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';

class ChatScreen extends StatelessWidget {
  const ChatScreen({super.key});

  Future<User> fetchUser(String uid) async {
    final completer = Completer<User>();
    CometChat.getUser(
      uid,
      onSuccess: (user) => completer.complete(user),
      onError: (error) => completer.completeError(error),
    );
    return completer.future;
  }

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<User>(
      future: fetchUser("cometchat-uid-2"),  // Replace with target UID
      builder: (context, snapshot) {
        if (snapshot.connectionState == ConnectionState.waiting) {
          return const Scaffold(
            body: Center(child: CircularProgressIndicator()),
          );
        }
        if (snapshot.hasError) {
          return Scaffold(
            body: Center(child: Text('Error: ${snapshot.error}')),
          );
        }
        final user = snapshot.data!;
        return Scaffold(
          appBar: CometChatMessageHeader(user: user),
          body: SafeArea(
            child: Column(
              children: [
                Expanded(child: CometChatMessageList(user: user)),
                CometChatMessageComposer(user: user),
              ],
            ),
          ),
        );
      },
    );
  }
}
```

Key points:

* `CometChat.getUser(uid)` fetches the user object — you need a real user object, not a manually constructed one.
* Pass either `user` or `group` to the message components, never both.

***

## Switching to Group Chat

To load a group chat instead, use `CometChat.getGroup()`:

```dart theme={null}
Future<Group> fetchGroup(String guid) async {
  final completer = Completer<Group>();
  CometChat.getGroup(
    guid,
    onSuccess: (group) => completer.complete(group),
    onError: (error) => completer.completeError(error),
  );
  return completer.future;
}

// Then in build():
FutureBuilder<Group>(
  future: fetchGroup("your-group-guid"),
  builder: (context, snapshot) {
    if (snapshot.hasData) {
      final group = snapshot.data!;
      return Scaffold(
        appBar: CometChatMessageHeader(group: group),
        body: Column(
          children: [
            Expanded(child: CometChatMessageList(group: group)),
            CometChatMessageComposer(group: group),
          ],
        ),
      );
    }
    return const CircularProgressIndicator();
  },
)
```

***

## Step 2 — Run the App

```bash theme={null}
flutter run
```

You should see the chat window load with the conversation for the UID you set.

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Message List" icon="message" href="/ui-kit/flutter/v5/message-list">
    Customize the message view
  </Card>

  <Card title="Conversations" icon="list" href="/ui-kit/flutter/v5/conversations">
    Add a conversation list
  </Card>

  <Card title="Theming" icon="paintbrush" href="/ui-kit/flutter/v5/theme-introduction">
    Customize colors and styles
  </Card>

  <Card title="Events" icon="bolt" href="/ui-kit/flutter/v5/events">
    Handle real-time events
  </Card>
</CardGroup>
