> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clariodesk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Flutter quickstart

> In-app support for Flutter apps: drop the SDK in, get a live ticket UI, with no backend code on your side.

The ClarioDesk Flutter SDK (`clariodesk` on pub.dev) gives you a hardware-bound
device identity and a live ticket thread with a few method calls.

## Install

```bash theme={null}
flutter pub add clariodesk
```

Requires Flutter ≥ 3.41 / Dart ≥ 3.11, iOS 13+, Android API 23+.

## Initialize

The first `init` generates the hardware key and registers the device with the
backend. Subsequent launches reuse the existing key with no network call.

```dart theme={null}
import 'package:clariodesk/clariodesk.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await ClarioDesk.init(apiKey: 'pk_live_…');
  runApp(const MyApp());
}
```

## Identify the user

Call this after your own auth knows who the user is. It's optional, pure
metadata. See [lifecycle](/flutter/lifecycle) for the four events you should
wire (especially case 1, which covers users who were logged in before you
installed the SDK).

```dart theme={null}
await ClarioDesk.identify(
  externalId: hostUser.id,
  email: hostUser.email,
  traits: {'plan': 'pro'},
);
```

## File a ticket

```dart theme={null}
final t = await ClarioDesk.createTicket(
  subject: 'Upload broken',
  body: 'Tapping upload does nothing.',
);
```

## Stream the inbox & a thread

Reactive reads: both auto-prime, then live-update.

```dart theme={null}
// Inbox
StreamBuilder<List<Ticket>>(
  stream: ClarioDesk.ticketsStream(),
  builder: (_, snap) {
    final tickets = snap.data ?? const [];
    return ListView(/* render tickets */);
  },
);

// A single thread
StreamBuilder<List<Message>>(
  stream: ClarioDesk.messagesStream(t.id),
  builder: (_, snap) => /* render messages */,
);
```

## Send a reply

```dart theme={null}
await ClarioDesk.sendMessage(t.id, 'Still happening on 1.4.2');
```

## Run the example app

```bash theme={null}
cd example
flutter run --dart-define=CLARIODESK_API_KEY=pk_live_…
```

<CardGroup cols={2}>
  <Card title="Lifecycle integration" icon="user-check" href="/flutter/lifecycle">
    Wire login, launch, logout, and user-switch.
  </Card>

  <Card title="Prebuilt UI" icon="layout-panel-left" href="/flutter/prebuilt-ui">
    Skip building the UI. Open a themeable inbox in one call.
  </Card>
</CardGroup>
