> 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/run-workflow/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

Execute a workflow over HTTP and read `result`, `state`, and `executionId`.

## Complete example

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

const userId = 'workflow-runner';

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

  await notifier.connect();

  final searchRun = await notifier.runWorkflow(
    workflow: intentRouterWorkflow,
    input: 'How do refunds work?',
  );

  print('Branch: ${searchRun.result}');
  print('Execution: ${searchRun.executionId}');

  final generalRun = await notifier.runWorkflow(
    workflow: intentRouterWorkflow,
    input: 'What is your name?',
  );

  print('Branch: ${generalRun.result}');
}
```

## HTTP handler pattern

```dart
Future<void> handleSupportWorkflow(
  DNotifier notifier,
  String question,
  HttpResponse response,
) async {
  final run = await notifier.runWorkflow(
    workflow: intentRouterWorkflow,
    input: question,
  );

  response.headers.contentType = ContentType.json;
  response.write(jsonEncode({
    'result': run.result,
    'executionId': run.executionId,
  }));
  await response.close();
}
```

## Blog pipeline input

```dart
final run = await notifier.runWorkflow(
  workflow: blogArticleWorkflow,
  input: {
    'topic': 'Building AI workflows with DNotifier',
    'keywords': ['workflow', 'sdk', 'observability'],
    'audience': 'developers',
    'tone': 'professional',
    'wordCount': 900,
  },
);

final result = run.result;
if (result is Map) {
  print((result['article'] as String?)?.substring(0, 200));
  print(result['seo']);
}
```

## Learn more

* [**Workflow observability**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/observability.md)
* [**Example: Multi-agent pipeline**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/example-multi-agent/dart-flutter.md)
