> 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/workflows-and-agents/example-tool-agent/dart-flutter.md).

# Dart / Flutter

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

Future<void> main() async {
  final notifier = DNotifier(
    appId: Platform.environment['DNOTIFIER_APP_ID']!,
    secret: Platform.environment['DNOTIFIER_SECRET']!,
    transport: 'http',
    userId: 'demo-user',
    permissionEnforcement: 'disabled', // use 'backend' in production
    onAgentEvent: (event) {
      print('[agent] ${event['type']} ${event['toolId']}');
    },
  );

  await notifier.connect();

  final add = notifier.tools.register(
    name: 'math.add',
    description: 'Add two numbers and return { sum }',
    inputSchema: {
      'type': 'object',
      'properties': {
        'a': {'type': 'number'},
        'b': {'type': 'number'},
      },
      'required': ['a', 'b'],
    },
    execute: (input, context) async {
      final a = (input['a'] as num).toDouble();
      final b = (input['b'] as num).toDouble();
      return {'sum': a + b};
    },
  );

  final agent = defineAgent(
    name: 'math-assistant',
    instructions:
        'You are a calculator assistant. Use math.add for addition. Reply briefly.',
    provider: 'open_ai',
    model: 'gpt-4o',
    observability: true,
    tools: [add],
    permissions: {'math.add': ['execute']},
  );

  final result = await notifier.runAgent(
    agent,
    input: 'What is 21 + 21?',
    maxToolRounds: 4,
  );

  print('output: ${result['output']}');
  print('finishReason: ${result['finishReason']}');
  print('executionId: ${result['executionId']}');
}
```

## Learn more

* [**Tools & MCP — Dart**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/tools-and-mcp/dart-flutter.md)
* [**MCP Mermaid example**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/example-mcp-agent/dart-flutter.md)
