---
updatedAt: 2026-08-07T08:13:47.000Z
agentTools:
  projectIndex: https://docs.yespo.io/llms.txt
---

# Flutter Recommendations

# Recommendations

Use Reteno recommendations to personalize products or services in your Flutter application.

## Get Typed Recommendations

```dart
final recommendations = await Reteno().getRecommendations(
  recomenedationVariantId: 'r1107v1482',
  productIds: ['240-LV09', '24-WG080'],
  categoryId: 'Default Category/Training/Video Download',
  filters: [
    RetenoRecomendationFilter(
      name: 'filter_name',
      values: ['filter_value'],
    ),
  ],
  fields: ['productId', 'name', 'descr', 'imageUrl', 'price'],
);
```

`recomenedationVariantId` and `productIds` are required by the Flutter API. `categoryId`, `filters`, and `fields` are optional. The spelling of `recomenedationVariantId` and `RetenoRecomendationFilter` reflects the current public API. Each filter requires `name` (`String`) and `values` (`List<String>`).

The configured algorithm decides which targeting input must be filled: product-based variants need a non-empty `productIds`, category-based variants need a non-empty `categoryId` with `productIds: []`, and personal variants use `productIds: []` without `categoryId`. Omitting the required input can fail with a server error.

To request every configured response field, omit `fields` or pass `null`. Do not pass `fields: []`: Android sends the empty list while iOS omits it, so the platforms can return different field sets.

Filters are Android-only in practice. The iOS bridge replaces `filters` with an empty list in both recommendation methods.

The method returns `List<RetenoRecommendation>`. `productId` is always available; the other properties are nullable and depend on the requested `fields` and the recommendation response:

| Type             | Properties                                                                                                                                                                                                                                                                                                                                                           |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `String`         | `productId`                                                                                                                                                                                                                                                                                                                                                          |
| `double?`        | `price`                                                                                                                                                                                                                                                                                                                                                              |
| `List<String>?`  | `category`, `categoryAncestor`, `categoryLayout`, `categoryParent`                                                                                                                                                                                                                                                                                                   |
| `String?`        | `name`, `description`, `imageUrl`, `url`, `itemGroup`, `nameKeyword`, `productIdAlt`, `dateCreatedAs`, `dateCreatedEs`, `dateModifiedAs`                                                                                                                                                                                                                             |
| `String?` (tags) | `tagsAllCategoryNames`, `tagsBestseller`, `tagsCashback`, `tagsCategoryBestseller`, `tagsCredit`, `tagsDelivery`, `tagsDescriptionPriceRange`, `tagsDiscount`, `tagsHasPurchases21Days`, `tagsIsBestseller`, `tagsIsBestsellerByCategories`, `tagsItemGroupId`, `tagsNumPurchases21Days`, `tagsOldPrice`, `tagsOldprice`, `tagsPriceRange`, `tagsRating`, `tagsSale` |

The response field `descr` is exposed as `RetenoRecommendation.description`.

## Get the Platform JSON Response

Use `getRecommendationsJson()` when the configured response contains fields that are not represented by `RetenoRecommendation`:

```dart
final response = await Reteno().getRecommendationsJson(
  recomenedationVariantId: 'r1107v1482',
  productIds: ['240-LV09', '24-WG080'],
  categoryId: 'Default Category/Training/Video Download',
  filters: [
    RetenoRecomendationFilter(
      name: 'filter_name',
      values: ['filter_value'],
    ),
  ],
  fields: ['productId', 'name', 'customField'],
);
```

The method takes the same parameters as the typed method, returns `Map<String, dynamic>`, and has the same iOS filter limitation.

The returned map is not identical across platforms. Android returns the whole parsed top-level object, or `{'response': '<raw response string>'}` when parsing fails. iOS returns only `{'recoms': [...]}`, with an empty list when `recoms` is missing. Treat `recoms` as the only cross-platform key.

## Log Recommendation Events

Log an `impression` when a recommendation is displayed and a `click` when the user selects it:

```dart
final event = RetenoRecomEvent(
  eventType: RetenoRecomEventType.impression,
  dateOccurred: DateTime.now(),
  productId: 'product_id',
);

final events = RetenoRecomEvents(
  recomVariantId: 'recom_variant_id',
  events: [event],
);

await Reteno().logRecommendationsEvent(events);
```

`RetenoRecomEvent` requires `eventType`, `dateOccurred`, and `productId`. `RetenoRecomEvents` requires `recomVariantId` and `events` (`List<RetenoRecomEvent?>`); despite the nullable element type, `null` entries are not supported.

The returned `Future` completes after the events are dispatched to the native SDK, not after the backend ingests them.

iOS ignores `dateOccurred` and substitutes the current native time, because the bridge does not accept the fractional-second timestamps Dart sends. Android preserves the value.