getLocalization method

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

Returns an instance of Localization.

Returns the Localization object for the provide Country code, and if none is provided the general localization object is returned. It provides information regarding supported Languages, Countrys and Currencies suuported by each country.

Implementation

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

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