genUiActionHandler function
Builds a VoidCallback that performs an A2UI action the same way the core
Button does.
Returns null when actionData is null, so widgets that treat a null
callback as "disabled" keep that behavior when the model omits the action.
Supported shapes of actionData:
{"event": {"name": "...", "context": {...}}}resolvescontextagainstctx.dataContextand dispatches aUserActionEventwithsourceComponentIdset toctx.id.{"functionCall": {"call": "...", "args": {...}}}resolves the call throughctx.dataContext.resolve.closeModalpops the current route.
The returned callback never throws: every failure is reported through
ctx.reportError and logged with genui's logger. Malformed action data is
reported as an A2uiValidationException so the model receives the actual
message (genui forwards other error types as a generic internal error).
Implementation
VoidCallback? genUiActionHandler(CatalogItemContext ctx, Object? actionData) {
if (actionData == null) return null;
return () {
unawaited(_perform(ctx, actionData));
};
}