MicroSurvey), one widget
(InsitoProvider), and one navigator observer (InsitoNavigatorObserver).
Everything else is a type or theme helper.
Import
MicroSurvey, InsitoConfig,
UserProperties, InsitoProvider, InsitoAppearance,
InsitoNavigatorObserver, the InsitoEvent enum + InsitoEventPayload, the
theme types (ThemePreset, InsitoTheme, InsitoThemeOverrides, …,
resolveTheme, themePresets), BrandConfig, and the survey types
(ActiveSurvey, Answer, SurveyQuestion, QuestionType, SdkState, …).
MicroSurvey
A static facade over the SDK singleton. Holds the state machine and the
imperative methods you call from your app.
MicroSurvey.init(config) → Future<void>
Boots the SDK. Call once, as early as possible (top of main() after
WidgetsFlutterBinding.ensureInitialized()). Subsequent calls are ignored with
a debug warning.
Project API key. Format:
proj_xxx. Throws if malformed.Override the API base URL — useful for staging or self-hosted instances.
Per-request timeout in milliseconds. Lowering this on flaky networks routes
more responses through the offline queue.
Toggles internal
debugPrint output. Recommended: debug: kDebugMode.production / staging / development. Forwarded as respondent metadata for
audience filtering.Base preset for the survey modal. See Theming.
Partial token overrides deep-merged on top of the preset (and any Brand Kit).
Declare trigger events for the dashboard registry. See
Configure.
Declare screens for the dashboard registry.
MicroSurvey.identify(user) → Future<void>
Associates subsequent triggers with a stable user. Cached for 24 hours per
userId, so repeat calls don’t hit the network. Takes a UserProperties:
Stable, unique identifier for your user. Most teams pass their database user
ID. Do NOT pass an email or anything PII unless you’ve configured PII handling
on your account.
e.g.
"ios", "android". Used by analytics for platform breakdowns.Your app’s build version, e.g.
"2.7.0". Surfaces in the dashboard so you can
correlate feedback with releases.Free-form device-level key/value pairs. Merged on top of the SDK’s
auto-captured device metadata
— your keys win on a collision.
Custom, business-level user properties (e.g.
plan: "premium",
transactionsThisMonth: 14). Discovered into the dashboard
User Properties registry as type-aware audience
filters. Only String / num / bool values are kept. Call identify()
again whenever a value changes — the API always uses the most recent value.MicroSurvey.trigger(eventName) → Future<void>
Fires a trigger by name. The server decides whether to show a survey; if so, the
modal renders inside InsitoProvider.
Lowercase snake_case event name configured against a survey in the dashboard
(e.g.
"checkout_completed"). See Triggers.- Not initialised → no-op + debug warning.
- No
identify()call yet → no-op + debug warning. - A survey is already active → no-op + debug log.
MicroSurvey.evaluate([reason, options]) → Future<void>
Re-checks the auto-evaluated trigger types for the current user (e.g. session
count / days-since-install rules) without a specific event name.
MicroSurvey.submitResponse(surveyId, answers, [options]) → Future<SubmitResponseResult>
Used internally by the built-in modal. Call it directly only if you’re rendering
your own question UI.
The active survey’s ID — usually
MicroSurvey.activeSurvey?.surveyId.MicroSurvey.savePartialProgress(surveyId, answers, [existingResponseId]) → Future<String?>
Persists partial answers (autosave) mid-survey, returning the response ID so
subsequent saves update the same row.
MicroSurvey.dismissSurvey() → void
Closes the active modal without submitting. Emits surveyDismissed. Used by the
built-in close button.
MicroSurvey.on(event, listener) / MicroSurvey.off(event, listener)
Subscribe to lifecycle events. on() returns an unsubscribe function.
MicroSurvey.recordScreenVisit(name) → void
Records a screen visit and fires screen_viewed:<name> when a user is
identified. InsitoNavigatorObserver calls this for you; use it directly for
routing that isn’t Navigator-driven. See
Screen tracking.
Read-only state
Widgets
InsitoProvider
Renders the survey modal above your app. Wrap it around your MaterialApp.
Your app (typically a
MaterialApp).Drives the light/dark scheme for
themeMode: "auto" surveys. system follows
the device; light / dark mirror your app’s own theme. See
Theming.InsitoNavigatorObserver
A NavigatorObserver that reports screen visits. Add it to
MaterialApp(navigatorObservers: [InsitoNavigatorObserver()]). See
Screen tracking.
Theme helpers
resolveTheme(preset, [overrides]) → InsitoTheme
Builds a fully-populated InsitoTheme from a ThemePreset plus optional
InsitoThemeOverrides. Useful for previewing a theme outside the SDK.
themePresets
The raw preset map: Map<ThemePreset, InsitoTheme>. Each entry is a complete
InsitoTheme.
Types
Answer
nps:valueis anint0–10.rating:valueis anint1–5.multipleChoice:valueis aString(single-select) orList<String>(multi-select).openText:valueis aString.
SdkState
idle→ user can firetrigger().loading→ trigger in flight to the server.surveyActive→ modal is on screen.completed→ response submitted, modal closed (transient).
QuestionType
welcomeScreen / endScreen are
copy/CTA-only steps. Each maps to a wire value (nps, rating,
multiple_choice, open_text, welcome_screen, end_screen).