Skip to content

Installation

Install the packages that match the surface you are building.

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.tech

Don'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:

pubspec.yaml

Then resolve dependencies:

Setup

1. Pick a storage adapter

For local development and tests, use the built-in in-memory adapter:

dart
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:

dart
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.

dart
final context = RegistryTypeResolver(
  descriptors: [
    DefaultWorkflowDescriptor(),
    myWorkflowDescriptor,
  ],
);

3. Initialize the engine

dart
final engine = WorkflowEngine(
  context: context,
  storage: storage,
  executionMode: ExecutionMode.production,
);

await engine.initialize();

4. Register or load workflows

For code-built workflows:

dart
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:

dart
final definition = await engine.storage.workflows.getByCode('approval');
if (definition != null) {
  engine.loadWorkflowDefinition(definition);
}

5. Start an instance

dart
final instance = await engine.startWorkflow(
  workflowCode: 'hello',
  input: {'name': 'Pavan'},
  userId: 'user-1',
);

Optional Packages

PackageUse when
vyuh_workflow_storage_supabasePersist workflow definitions, instances, user tasks, and events in Supabase/PostgreSQL.
cdx_workflow_typesShare approval and inbox wire contracts between server and Flutter clients.
cdx_workflow_templatesInstall canonical workflow templates such as the shared approval workflow.
cdx_feature_workflowsAdd workflow inbox widgets, action bars, status cards, and activity timelines to a Vyuh Flutter app.
vyuh_workflow_protocolCommunicate between an editor/client and an engine through typed commands, responses, and events.
vyuh_workflow_editorEmbed the visual workflow editor and simulation UI in Flutter.

What's Next?