isRtl function

bool isRtl([
  1. String? locale
])

Returns true if locale represents a right-to-left (RTL) script.

Tests language subtags against known RTL scripts (Arabic, Hebrew, Persian, Urdu, etc.). When locale is omitted, defaults to testing the active BloomI18n.instance.locale signal.

isRtl('ar-EG'); // true
isRtl('en-US'); // false

See also:

Implementation

bool isRtl([String? locale]) {
  final loc = (locale ?? BloomI18n.instance.locale.value).replaceAll('_', '-').toLowerCase();
  final lang = loc.split('-').first;
  return _rtlLanguages.contains(lang);
}