From 6b846218163e035ca90c33e73028388e6a7e8227 Mon Sep 17 00:00:00 2001 From: Ahmed Hamdi Radwan Date: Thu, 11 Sep 2025 11:08:03 +0400 Subject: [PATCH] fix(rtl): keep dial code '+' on the left via LRM Wrap dial code with U+200E (LRM) in display strings to prevent bidi reordering in RTL. Refs #67 --- lib/src/country_code.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/country_code.dart b/lib/src/country_code.dart index 069f0e8..2d238e0 100644 --- a/lib/src/country_code.dart +++ b/lib/src/country_code.dart @@ -83,10 +83,17 @@ class CountryCode { ); } + static const String _lrm = '\u200E'; + String get _dialCodeLTR { + final dc = dialCode ?? ''; + if (dc.isEmpty) return dc; + return '$_lrm$dc$_lrm'; + } + @override - String toString() => "$dialCode"; + String toString() => _dialCodeLTR; - String toLongString() => "$dialCode ${toCountryStringOnly()}"; + String toLongString() => "$_dialCodeLTR ${toCountryStringOnly()}"; String toCountryStringOnly() { return '$_cleanName';