> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/ai/session-logging/dart-flutter.md). Agents can also search and read this documentation through its [MCP server](https://dnotifier.gitbook.io/product-docs/~gitbook/mcp).

# Dart / Flutter

Enable dashboard AI telemetry with **`logs: true`** on the `DNotifier` constructor.

## Complete example

```dart
import 'package:dnotifier/dnotifier.dart';

const userId = 'user-123';

Future<void> main() async {
  final notifier = DNotifier(
    appId: 'your-app-id',
    secret: 'your-app-secret',
    transport: 'http',
    userId: userId,
    logs: true,
    onConnected: () => print('Ready — logging enabled'),
    onMessage: (_) {},
  );

  await notifier.connect();

  await notifier.sendAI(
    senderId: userId,
    message: {
      'messages': [
        {'role': 'system', 'content': 'You are a concise assistant.'},
        {
          'role': 'user',
          'content': 'Explain session logging in one paragraph.',
        },
      ],
    },
  );
  // Check app.dnotifier.com → Logs
}
```

## Conditional logging

```dart
import 'dart:io';

final enableLogs = Platform.environment['DNOTIFIER_LOGS'] == 'true';

final notifier = DNotifier(
  appId: Platform.environment['DNOTIFIER_APP_ID']!,
  secret: Platform.environment['DNOTIFIER_SECRET']!,
  transport: 'http',
  userId: userId,
  logs: enableLogs,
  onConnected: () {},
  onMessage: (_) {},
);
```

## With session continuation

```dart
final first = await notifier.sendAI(
  senderId: userId,
  message: {'text': 'Start logged session.'},
);

final sessionId = _sessionIdFromResponse(first);

await notifier.sendAI(
  senderId: userId,
  sessionId: sessionId,
  message: {'text': 'Follow-up — also logged.'},
);

String? _sessionIdFromResponse(dynamic response) {
  if (response is Map) {
    final meta = response['metadata'];
    if (meta is Map) {
      final packet = meta['packet'];
      if (packet is Map) return packet['id']?.toString();
      return meta['id']?.toString();
    }
  }
  return null;
}
```

## Learn more

* [**Sessions**](https://dnotifier.gitbook.io/product-docs/ai/sessions/dart-flutter.md)
* [**Workflow observability**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/observability.md)
