buildButton function
Implementation
Widget buildButton(BuildContext context, OpenUiNode node) {
final label = node.props['label'] == null
? ''
: jsString(node.props['label']);
final enabled = node.props.boolean('disabled') != true && !node.isStreaming;
final button = ActionGate(
node: node,
prop: 'action',
enabled: enabled,
label: (_) => label,
sendLabel: true,
builder: (context, status, onTap) => IuiButton(
label: label,
icon: node.props.string('icon'),
variant: node.props.string('variant') ?? 'solid',
tone: node.props.string('color'),
size: node.props.string('size') ?? 'md',
phase: status?.phase,
onTap: onTap == null ? null : () => onTap(context),
),
);
if (node.props.boolean('block') == true) {
return SizedBox(width: double.infinity, child: button);
}
return Align(
alignment: AlignmentDirectional.centerStart,
widthFactor: 1,
heightFactor: 1,
child: button,
);
}