load method

Future<void> load()

Loads the localized country values from supported language codes.

Implementation

Future<void> load() async {
  late final String rawJson;
  try {
    rawJson = await svc.rootBundle.loadString(
      'packages/fl_country_code_picker_weebi/i18n/${locale.languageCode}.json',
    );
  } catch (_) {
    rawJson = await svc.rootBundle.loadString(
      'packages/fl_country_code_picker_weebi/i18n/en.json',
    );
  }

  final jsonMap = Map<String, String>.from(
    json.decode(rawJson) as Map<String, dynamic>,
  );

  _localizedCountries = jsonMap.map<String, String>(MapEntry.new);
}