getCountrySpecifications function

Map<String, CountrySpec> getCountrySpecifications()

Returns specifications for all countries, even those who are not members of IBAN registry. IBANRegistry field indicates if country is member of not.

// Validating IBAN form field after user selects his country
DropDownFormField<Country>(
  ...
  items: countries.map((Country country) => DropDownMenuButton<Country>(child: Text(country.name), value: country)
  ...
  onChanged: (Country? value) {
    // Find country
    var ibanCountry = ibantools.getCountrySpecifications()[value.code];
    // Add New value to "pattern" attribute to iban input text field
    final countryValidation = '${value.code}"[0-9]{2}${country.ibanCountry.substring(1).replaceAll("$","")}'
  }
)

Implementation

Map<String, CountrySpec> getCountrySpecifications() {
  Map<String, CountrySpec> countyMap = const <String, CountrySpec>{};
  countrySpecs.forEach((String key, CountrySpec value) {
    final CountrySpec? county = countrySpecs[key];
    countyMap[key] = CountrySpec(
        chars: county?.chars,
        bbanRegexp: county?.bbanRegexp,
        ibanRegistry: county?.ibanRegistry ?? false,
        sepa: county?.sepa ?? false);
  });

  return countyMap;
}