getAutocompletedSuggestions static method

Future<List> getAutocompletedSuggestions(
  1. TagType taxonomyType, {
  2. String input = '',
  3. OpenFoodFactsLanguage language = OpenFoodFactsLanguage.ENGLISH,
  4. QueryType? queryType,
  5. int limit = 25,
})

Returns suggestions.

The limit has a max value of 400 on the server side.

Implementation

static Future<List<dynamic>> getAutocompletedSuggestions(
  final TagType taxonomyType, {
  final String input = '',
  final OpenFoodFactsLanguage language = OpenFoodFactsLanguage.ENGLISH,
  final QueryType? queryType,
  final int limit = 25,
}) async {
  final Uri uri = UriHelper.getPostUri(
    path: '/cgi/suggest.pl',
    queryType: queryType,
  );
  final Map<String, String> queryParameters = <String, String>{
    'tagtype': taxonomyType.offTag,
    'term': input,
    'lc': language.offTag,
    'limit': limit.toString(),
  };
  final Response response = await HttpHelper().doPostRequest(
    uri,
    queryParameters,
    null,
    queryType: queryType,
    addCredentialsToBody: false,
  );
  return json.decode(response.body);
}