setCountry static method

Future<bool> setCountry(
  1. UserPreferences userPreferences,
  2. String isoCode
)

Sets the global country for API queries: explicit choice by the user.

Returns true if the isoCode was correctly detected.

Implementation

static Future<bool> setCountry(
  UserPreferences userPreferences,
  String isoCode,
) async {
  final OpenFoodFactsCountry? country = OpenFoodFactsCountry.fromOffTag(
    isoCode,
  );
  if (country == null) {
    return false;
  }
  await _setCountry(userPreferences, country);
  return true;
}