greetingRowFor function
- SiteConfig? config,
- HatangLocale locale, {
- required bool online,
The greeting for an empty conversation, or null when the site has none
or turned it off (greeting_options; older gateways: always shown). The
web widget hides it on narrow screens unless on_mobile is set; the SDK
treats every platform (tablets and desktop included) as mobile. With
sender: online_agent and someone online, the first agent's name signs
it.
Implementation
GreetingRow? greetingRowFor(SiteConfig? config, HatangLocale locale, {required bool online}) {
if (config == null) return null;
final options = config.greetingOptions;
if (options != null && !(options.enabled && options.onMobile)) return null;
final text = config.greetingFor(locale);
if (text == null) return null;
final signed = options?.sender == GreetingSender.onlineAgent && online && config.agentAvatars.isNotEmpty;
final name = signed ? config.agentAvatars.first.name.trim() : '';
return GreetingRow(text, sender: name.isEmpty ? null : name);
}