Installation
Get started with the Vyuh Workflow Engine in your Dart application.
Requirements
- Dart SDK 3.0 or higher
- Flutter 3.10+ (if using with Flutter)
Add Dependency
Add vyuh_workflow_engine to your pubspec.yaml:
yaml
dependencies:
vyuh_workflow_engine: ^1.0.0Then run:
bash
dart pub getOr with Flutter:
bash
flutter pub getBasic Setup
1. Create Context and Storage
The workflow engine requires a deserialization context and storage. For development and testing, use the in-memory storage:
dart
import 'package:vyuh_workflow_engine/vyuh_workflow_engine.dart';
// Create context with descriptors
final context = RegistryDeserializationContext(
descriptors: [DefaultWorkflowDescriptor()],
);
// Create in-memory storage
final storage = InMemoryStorage(context: context);For production, implement the WorkflowStorage interface for your database (PostgreSQL, MongoDB, SQL Server, etc.).
2. Initialize the Engine
dart
final engine = WorkflowEngine(
context: context,
storage: storage,
);
await engine.initialize();3. Define and Register a Workflow
dart
final workflow = WorkflowBuilder('HELLO', 'Hello World Workflow')
.start('begin')
.task('greet', name: 'Greet User', execute: (ctx) async {
print('Hello, ${ctx.input['name']}!');
return {'greeted': true};
})
.end('done')
.connect('begin', 'greet')
.connect('greet', 'done')
.build();
engine.registerWorkflow(workflow);4. Start a Workflow Instance
dart
final instance = await engine.startWorkflow(
workflowCode: workflow.code,
input: {'name': 'World'},
);
print('Workflow completed with status: ${instance.status}');What's Next?
- Quick Start - Build your first approval workflow
- Core Philosophy - Understand the design principles
- Architecture - Learn how the engine works