resolveDirection method
auto follows the copy: right-to-left when the first strong character is
Arabic / Hebrew script — the same rule the console preview uses.
Implementation
TextDirection resolveDirection(TextDirection ambient) {
if (direction == 'rtl') return TextDirection.rtl;
if (direction == 'ltr') return TextDirection.ltr;
for (final b in blocks) {
final text = switch (b) {
NexusInAppHeadingBlock(:final text) || NexusInAppTextBlock(:final text) || NexusInAppBadgeBlock(:final text) => text,
NexusInAppButtonsBlock(:final items) => items.map((i) => i.text).join(' '),
NexusInAppCarouselBlock(:final cards) => cards.map((c) => '${c.title} ${c.body}').join(' '),
_ => '',
};
for (final r in text.runes) {
if (_isRtl(r)) return TextDirection.rtl;
if (_isLtr(r)) return TextDirection.ltr;
}
}
return ambient;
}