getKnowledgePanels static method

  1. @Deprecated('Use getProduct with field [ProductField.KNOWLEDGE_PANELS] instead')
Future<KnowledgePanels> getKnowledgePanels(
  1. ProductQueryConfiguration configuration,
  2. QueryType queryType
)

Returns all KnowledgePanels for a product.

Implementation

// TODO: deprecated from 2022-01-22; remove when old enough
@Deprecated(
    'Use getProduct with field [ProductField.KNOWLEDGE_PANELS] instead')
static Future<KnowledgePanels> getKnowledgePanels(
  ProductQueryConfiguration configuration,
  QueryType queryType,
) async {
  try {
    final ProductResult productResult = await getProduct(
      ProductQueryConfiguration(
        configuration.barcode,
        language: configuration.language,
        country: configuration.country,
        fields: [ProductField.KNOWLEDGE_PANELS],
        version: ProductQueryVersion.v2,
      ),
      user: null,
      queryType: queryType,
    );
    return productResult.product!.knowledgePanels!;
  } catch (exception, stackTrace) {
    // TODO(jasmeetsingh): Capture the exception in Sentry and don't log it here.
    log('Exception $exception has occurred.\nStacktrace: \n$stackTrace');
    return KnowledgePanels.empty();
  }
}