Requirements
- Dart SDK 3.9 or higher
- Flutter only when using editor or feature packages
Authenticate with pub.vyuh.tech first
`vyuh_workflow_engine` is hosted on the private pub.vyuh.tech registry. Before running pub get, register a Bearer token issued by Vyuh Technologies based on your plan.
Run the one-time setup:
dart pub token add https://pub.vyuh.techDon't have a token yet? Email ask@vyuh.tech to request one. For full details (CI, Docker, rotation, troubleshooting), see the Pub Token Setup guide.
Add Dependencies
Add vyuh_workflow_engine to your pubspec.yaml as a hosted dependency:
Then resolve dependencies:
Setup
1. Pick a storage adapter
For local development and tests, use the built-in in-memory adapter:
import 'package:vyuh_workflow_engine/vyuh_workflow_engine.dart';
final storage = InMemoryStorage();For Supabase/PostgreSQL deployments, add vyuh_workflow_storage_supabase and create a SupabaseStorage:
import 'package:supabase/supabase.dart';
import 'package:vyuh_workflow_storage_supabase/vyuh_workflow_storage_supabase.dart';
final storage = SupabaseStorage(
client: SupabaseClient(url, serviceRoleKey),
config: const SupabaseStorageConfig(
schema: 'elog',
definitionsTable: 'workflows',
instancesTable: 'workflow_instances',
userTasksTable: 'workflow_user_tasks',
eventsTable: 'workflow_events',
),
);2. Create the resolver
The engine resolves executable types through descriptors. Include DefaultWorkflowDescriptor() plus any app or template descriptors.
final context = RegistryTypeResolver(
descriptors: [
DefaultWorkflowDescriptor(),
myWorkflowDescriptor,
],
);3. Initialize the engine
final engine = WorkflowEngine(
context: context,
storage: storage,
executionMode: ExecutionMode.production,
);
await engine.initialize();4. Register or load workflows
For code-built workflows:
final workflow = WorkflowBuilder('hello', 'Hello Workflow')
.start('start')
.task('greet', execute: (ctx) async {
return {'message': 'Hello ${ctx.getInitial<String>('name') ?? 'World'}'};
})
.end('done')
.build();
engine.registerWorkflow(workflow);For stored definitions:
final definition = await engine.storage.workflows.getByCode('approval');
if (definition != null) {
engine.loadWorkflowDefinition(definition);
}5. Start an instance
final instance = await engine.startWorkflow(
workflowCode: 'hello',
input: {'name': 'Pavan'},
userId: 'user-1',
);