searchProducts static method

Future<SearchResult> searchProducts(
  1. User? user,
  2. AbstractQueryConfiguration configuration, {
  3. required UriProductHelper uriHelper,
  4. required SearchProductsType type,
})

Implementation

static Future<SearchResult> searchProducts(
  User? user,
  AbstractQueryConfiguration configuration, {
  required UriProductHelper uriHelper,
  required SearchProductsType type,
}) async {
  await type.waitIfNeeded();

  // It's better to do the HTTP actions outside of "compute", because
  // there are init phases for HTTP (like user agent and SSL certificates)
  // that would need to be somehow replicated for a new "compute thread".
  // Besides, putting HTTP in "compute" wouldn't improve the performances.
  final Response response = await configuration.getResponse(user, uriHelper);
  TooManyRequestsException.check(response);

  final SearchResult result = await compute(_decodeProducts, response.body);
  _removeImages(result, configuration);
  return result;
}