tapButton method
Handle a button tap: report the click, surface the action, auto-track
event actions, copy copy values, then dismiss. Tappable images in a
designed message come through here too, with the image block's id.
Implementation
void tapButton(NexusInAppMessage m, NexusInAppButton b) {
unawaited(_report(m, 'click', buttonId: b.id));
final action = NexusInAppAction(
messageId: m.id, buttonId: b.id, action: b.action, url: b.url, event: b.event, value: b.value, variantId: m.variantId);
if (b.action == 'event' && (b.event ?? '').isNotEmpty) {
onTrackEvent?.call(b.event!);
}
if (b.action == 'copy' && (b.value ?? '').isNotEmpty) {
unawaited(Clipboard.setData(ClipboardData(text: b.value!)));
}
onAction?.call(action);
close();
}