replaceSubdomain static method
Replaces the subdomain of an URI with specific country and language.
Default language and country will be used as fallback, if available. For instance
- https://world.xxx... would be standard
- https://world-fr.xxx... would be "standard country" in French
- https://fr.xxx... would be France
- https://fr-es.xxx... would be France in Spanish
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,
);