applyCustomRegion method

void applyCustomRegion(
  1. Set<String>? customRegion
)

Define custom country code which may not recognized as country code yet or using as testing purpose.

customRegion can be null or a Set of String which contains two capital letter to satisify ISO 3166 alpha-2 standard.

Applying empty Set into customRegion will throws ArgumentError, and FormatException if does not obey the format of country code.

When customRegion contains country code that it defined in ISO 3166 already, the duplicated country codes will be excluded.

The applied customRegion belongs with current instance only which will be purged once factoryReset called.

This method does not allows for IntlScriptRecognizer.delicated to prevent unwanted modification that UnsupportedError will be thrown if called.

If the customRegion no longer contains the previous custom country code, those will be removed if they assign before.

Implementation

void applyCustomRegion(Set<String>? customRegion) {
  if (customRegion != null) {
    if (customRegion.isEmpty) {
      throw ArgumentError.value(customRegion, "customRegion",
          "It must be either `null` or non-empty set of string");
    }

    _customRegionApplier(customRegion);
  } else {
    _customRegion = <String>{};
  }

  _localCountryMapper
      .removeWhere((key, value) => !_availableRegion.contains(value));
}