phoneCode method
Returns a string representation of the phone code for this Idd object.
The returned string has the format <leading><root><suffix>, where
<leading> is the given leading parameter (defaults to +), <root>
is the root field of this Idd object, and <suffix> is the first
value in the suffixes list of this Idd object if it has a single
suffix value, and an empty string otherwise.
When isRtl is true, the leading symbol is moved to the end of the
string to ensure correct display in right-to-left locales (e.g., Arabic).
Example usage:
import 'package:sealed_countries/sealed_countries.dart';
void main() {
final idd = const Idd(root: 3, suffixes: [81]);
assert(idd.phoneCode() == '+381');
assert(idd.phoneCode(isRtl: true) == '381+');
}
Implementation
String phoneCode({String leading = "+", bool isRtl = false}) {
final suffix = hasSingleSuffix ? "${suffixes.first}" : "";
return isRtl ? "$root$suffix$leading" : "$leading$root$suffix";
}