replaceSubdomain static method

Uri replaceSubdomain(
  1. Uri uri, {
  2. OpenFoodFactsLanguage? language,
  3. OpenFoodFactsCountry? country,
})

Replaces the subdomain of an URI with specific country and language.

Default language and country will be used as fallback, if available. For instance

Implementation

static Uri replaceSubdomain(
  final Uri uri, {
  OpenFoodFactsLanguage? language,
  OpenFoodFactsCountry? country,
}) =>
    replaceSubdomainWithCodes(
      uri,
      languageCode: language?.code ??
          (OpenFoodAPIConfiguration.globalLanguages != null &&
                  OpenFoodAPIConfiguration.globalLanguages!.isNotEmpty
              ? OpenFoodAPIConfiguration.globalLanguages![0].code
              : null),
      countryCode:
          country?.offTag ?? OpenFoodAPIConfiguration.globalCountry?.offTag,
    );