Flutter
The SoluCXWidget is a Flutter widget that allows integration with the SoluCX survey system. It offers different types
of widgets that can be displayed in various positions on the screen, such as top, bottom, modal, or inline.
Since version 2.0.0, whether the widget can be shown at all is decided entirely by widget-api (sampling, interval rules, max attempts, etc.) — the SDK no longer holds any local state about previous attempts or visits. See Availability check below.
Features
- Support for different widget types:
bottom,top,modal,inline. - Widget visibility control.
- Survey height configured per journey (or set by the app), falling back to the height the page reports.
- Server-side blocking/availability rules via
widget-api(sampling, intervals, max attempts). - WebView integration to display web content.
- Lifecycle callbacks (
onPreOpen,onOpened,onBlocked,onClosed,onError,onCompleted,onPartialCompleted,onResize) for observability and analytics integration.
Getting started
Prerequisites
- Flutter SDK
- Project dependencies listed in
pubspec.yaml - Internet permission on Android and iOS
Installation
Add SoluCXWidget to your Flutter project:
Setup
Android
Add the following permission to your AndroidManifest.xml file:
iOS
No extra setup is needed. Since 2.0.0 the survey is only loaded from https addresses, so there is no need to allow insecure connections in Info.plist. If you added NSAllowsArbitraryLoads for 1.x, you can remove it.
Usage
Here is a basic example of how to use SoluCXWidget:
Migrating from 1.x
Version 2.0.0 brings breaking changes from 1.x:
journeyand a customer identifier (clientId,cpforemail) are now required. Without them,onErrorfires and the survey never opens.- The
retryAttempts,retryInterval,collectIntervalandcollectPartialIntervaloptions were replaced by the SoluCXWidgetOptions rules. When omitted, the journey configuration applies. - The SDK no longer stores attempts and displays on the device, and
SoluCXWidgetService/StorageRepositorywere removed. To provide that history, use WidgetTimestampOverrides. onBlockednow receives the block reason (reason), and there are new callbacks:onPreOpen,onErrorandonResize.cpfis sent asdocumentandratingasscore(only when numeric);attemptIdandgenderare no longer sent.- The widget usage events sent to SoluCX can be turned off by SoluCX, with no change to the app.
Interfaces
SoluCXKey
A type alias for String used as a unique identifier for the SoluCX widget.
SoluCXWidget
A Flutter widget that integrates with the SoluCX survey system.
Properties
SoluCXWidget parameters
widgetOptions.type), falling back to bottom. An explicit local type always takes priority over the server's. widget-api's time-based rules (optional). See Availability check. widget-api confirms the survey can open, receiving the identifier used in the rules (clientId ?? cpf ?? email; the CPF is sent to widget-api as document), if any (optional). onPreOpen (optional). widget-api prevents the widget from opening, receiving the reason returned by the server (see BlockReason for the known values — not a closed set) (optional). onClosed. onPreOpen (optional). onPreOpen (optional). options.height or the journey's), but the widget then keeps the fixed height. Callbacks
Functions called at each step of the widget's lifecycle. All of them are optional. onPreOpen, onOpened, onCompleted and onPartialCompleted receive the identifier (String?) used for the blocking rules (clientId ?? cpf ?? email; the CPF is sent to widget-api as document), when any.
| Callback | Parameter | When it is called |
|---|---|---|
onPreOpen | userId: String? | Before the widget becomes visible, once widget-api allows the display |
onOpened | userId: String? | When the widget becomes visible on screen |
onBlocked | reason: String? | When widget-api prevents the display. See BlockReason |
onClosed | - | When the widget is closed, by the user or programmatically |
onError | message: String | When the availability check fails, or the survey reports an error |
onCompleted | userId: String? | When the user completes the full survey |
onPartialCompleted | userId: String? | When the user submits the main rating (NPS/CSAT/CES) — fires even if the survey is completed right after |
onResize | height: String | When the survey page reports its height |
BlockReason
Known reasons widget-api may return when it prevents the widget from opening. Not a closed set: on a downstream failure the server can also return an arbitrary error message in reason.
| Reason | Description |
|---|---|
BLOCKED_BY_NOT_ENABLED | Widget disabled (enabled: false) |
BLOCKED_BY_SAMPLING | Display not drawn by sampling (samplingPercentage) |
BLOCKED_BY_WIDGET_DISPLAY_ATTEMPT_INTERVAL | Within the interval after a display attempt |
BLOCKED_BY_WIDGET_FIRST_ACCESS_INTERVAL | Within the interval after the customer's first access |
BLOCKED_BY_WIDGET_DISPLAY_INTERVAL | Within the interval after a display |
BLOCKED_BY_WIDGET_DISMISS_INTERVAL | Within the interval after the widget is dismissed |
BLOCKED_BY_WIDGET_SUBMIT_INTERVAL | Within the interval after a full submission |
BLOCKED_BY_WIDGET_PARTIAL_SUBMIT_INTERVAL | Within the interval after a partial submission |
BLOCKED_BY_MAX_ATTEMPTS_EXCEEDED | Maximum number of display attempts reached |
SoluCXWidgetType
An enum representing the type of SoluCX widget.
bottom: Displays the widget at the bottom of the screen.top: Displays the widget at the top of the screen.modal: Displays the widget as a modal overlay.inline: Displays the widget inline within the existing layout.
SoluCXWidgetOptions
Overrides for widget-api's server-side blocking rules, sent with every availability check. All rule fields are optional: when omitted, the server uses whatever is configured for the journey.
options parameter
0.0 to 1.0). Default value: 1.0. Flutter-only — never sent to widget-api. false, blocks immediately with BLOCKED_BY_NOT_ENABLED. transactionId. While this limit isn't reached, the waitDaysAfterWidgetDisplay and waitDaysAfterWidgetDismiss intervals don't block; once it is reached, that experience is no longer shown (reason BLOCKED_BY_MAX_ATTEMPTS_EXCEEDED, or the interval's reason while one of those intervals is still running). Attempts are counted per transactionId: without it, the limit is never reached and those two intervals stop blocking. 0 turns the rule off. WidgetTimestampOverrides.lastFirstAccess when provided. WidgetTimestampOverrides
Pure pass-through overrides for widget-api's time-based rules. The SDK never persists these values — unlike previous versions' local quarantine model, the host app is responsible for storing each value and supplying the current one on every open.
timestampOverrides parameter
waitDaysAfterWidgetDisplayAttempt). waitDaysAfterWidgetFirstAccess). Without the override, the server falls back to the customer's real registration date. waitDaysAfterWidgetDisplay). waitDaysAfterWidgetDismiss). waitDaysAfterWidgetSubmit). waitDaysAfterWidgetPartialSubmit). Availability check
Since version 2.0.0, before displaying anything, SoluCXWidget calls POST /widget/available on widget-api with soluCXKey, data, timestampOverrides, options, and, when an explicit local type is provided, also type. The response decides everything:
available: true+url→onPreOpen(userId)fires, the WebView loadsurl, the widget becomes visible,onOpened(userId)fires. The survey height is the one set by the app inoptions.height; without it, the one configured for the journey (600 px by default), which takes priority over the height the page reports; without either, the page's height is used, and 300 px until it arrives.available: false+reason→onBlocked(reason)fires; the widget never opens.reasonis a plainString?, not a closed enum — see BlockReason for the known values, but the server can also return an arbitrary error message.- Network failure, timeout, or a malformed/incomplete response (including a successful response missing
url) → fails closed:onError(message)fires, the widget never opens. This never crashes the host app.
There is no local fallback — a widget-api outage means the survey doesn't open, by design.
Important: since this version a real soluCXKey and journey configured at SoluCX are required — there is no local/offline mode anymore. journey and a customer identifier (clientId, cpf or email) are mandatory: without them the check is rejected, onError fires and the survey never opens. survey does not replace journey. For customers SoluCX does not know yet, name is also required: without it, onBlocked fires and the survey never opens.
SoluCXWidgetData
A class containing the data to be sent to the SoluCX survey.
Properties
data parameter
widget-api since 2.0.0. onBlocked with Error creating Objects). Optional for customers SoluCX already knows. widget-api as document. widget-api since 2.0.0. widget-api as score, only when numeric. clientId, cpf or email): without them widget-api rejects the availability check, onError fires and the survey never opens. journey for that purpose.