getLocalization method

Future<Localization> getLocalization({
  1. String? countrycode,
  2. String? languageCode,
})

Returns an instance of Localization.

Returns the Localization object for the provided countrycode, If none is provided, falls back to countryCode / languageCode or the store's default localization. It provides information regarding supported Languages, Countrys and currencies supported by each country.

Implementation

Future<Localization> getLocalization({
  String? countrycode,
  String? languageCode,
}) async {
  final _options = WatchQueryOptions(
    document: gql(getLocalizationQuery),
    variables: {
      'country': _normalizeCountryCode(countrycode),
      'language': _normalizeLanguageCode(languageCode),
    },
    fetchPolicy: FetchPolicy.networkOnly,
  );
  final QueryResult result = await _graphQLClient!.query(_options);
  checkForError(result);

  return Localization.fromJson(result.data?['localization'] ?? const {});
}