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

# Integrate the Klaritics Flutter SDK in Your App

> Add the Klaritics SDK to your Flutter project, initialize with app_id and server_host, and log events and user properties from Dart.

The Klaritics Flutter SDK follows the same conventions as the Web and Android SDKs. It provides a Dart API that delegates to the native platform layers, so you can initialize and log events from Dart while the SDK handles Android and iOS specifics. Packaging and installation follow standard Flutter conventions.

## Installation

Add the dependency to your `pubspec.yaml`:

```yaml theme={null}
dependencies:
  klaritics_flutter_sdk: ^x.x.x
```

Replace `x.x.x` with the latest version number. Then run:

```bash theme={null}
flutter pub get
```

## Initialization

Import the SDK and initialize it with your `app_id` and `server_host` before logging any events:

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

Klaritics.init("YOUR_APP_ID", serverHost: "https://YOUR_SERVER_HOST");
```

The SDK will not initialize until both values are provided.

## Logging events

```dart theme={null}
// Standard analytics event
Klaritics.logEvent("ProductClicked", properties: {
  "product_id": "sku-123",
  "category": "electronics"
});

// Client-specific event
Klaritics.logClientEvent("CustomAction", properties: {
  "action_type": "swipe"
});
```

## User and session management

```dart theme={null}
// Identify the current user
Klaritics.setUserId("user@example.com");

// Attach user properties
Klaritics.setUserProperties({
  "plan": "pro",
  "signup_date": "2024-01-15"
});

// Start a new session
Klaritics.startNewSession();
```

## Important naming note

The client-facing class is `Klaritics`. Do not use `KlariticsSDK`, `KlariticsCore`, or any other variant in your application code.
