InvergeDocs
FlutterAPI reference

Surveys

Surveys in the Flutter SDK.

import 'package:nexus_flutter/nexus.dart';
SymbolKindSummary
NexusSurveysclassIn-product surveys.
NexusSurveyChoiceclass
NexusSurveyQuestionclass
NexusSurveyTriggerclass
NexusSurveyclass
SurveySubmittypedefPersists a response (partial or terminal).
NexusSurveyControllerclassDrives one survey: holds answers, step position, validity, and submit/dismiss.
NexusQuestionBuildertypedefOverride the rendering of a single question.
NexusSurveyViewclassThe built-in survey card.
NexusSurveyBuildertypedefFully replace the survey UI.
NexusSurveyOverlayclassHosts the currently-active survey above your app.

NexusSurveys

class

In-product surveys. Fetches the surveys a user is eligible for, decides which to show (auto-show for popover/banner types + event triggers), and submits answers. The rendering is done by NexusSurveyOverlay (default UI) or your own widget driven by NexusSurveyController.

View source

active

property
List<NexusSurvey> get active

All surveys the user is currently eligible for.

View source

current

field
final ValueNotifier<NexusSurvey?> current

The survey currently requested to display (null when none). The overlay listens to this.

View source

fetch()

method
Future<List<NexusSurvey>> fetch()

Fetch eligible surveys from the server (targeting/sampling/capping applied).

Returns Future<List<NexusSurvey>>

View source

onEvent()

method
void onEvent(String name)

Called when an analytics event fires — shows a survey gated on that event.

Parameters

Prop

Type

View source

show()

method
void show(NexusSurvey survey)

Present a specific survey now (e.g. from a "Give feedback" button).

Parameters

Prop

Type

View source

close()

method
void close()

Remove the current survey from the screen (called by the UI when done).

View source

byId()

method
NexusSurvey? byId(String id)

Parameters

Prop

Type

Returns NexusSurvey?

View source

respond()

method
Future<void> respond(NexusSurvey survey, Map<String, Object?> answers, {bool completed = false, bool dismissed = false})

Submit a response (partial, complete, or dismissed). Best-effort.

Parameters

Prop

Type

View source

dispose()

method
void dispose()
View source

NexusSurveyChoice

class View source

NexusSurveyChoice

constructor
const NexusSurveyChoice({required this.value, this.label, this.open = false})

Parameters

Prop

Type

View source

fromJson()

static method
static NexusSurveyChoice fromJson(dynamic json)

Parameters

Prop

Type

Returns NexusSurveyChoice

View source

display

property
String get display
View source

value

field
final String value
View source

label

field
final String? label
View source

open

field
final bool open
View source

NexusSurveyQuestion

class View source

NexusSurveyQuestion

constructor
const NexusSurveyQuestion({required this.id, required this.type, required this.label, this.description, this.required = false, this.choices = const [], this.display, this.scaleMin, this.scaleMax, this.lowerLabel, this.upperLabel, this.buttonText, this.buttonUrl})

Parameters

Prop

Type

View source

fromJson()

static method
static NexusSurveyQuestion fromJson(Map<String, dynamic> m)

Parameters

Prop

Type

Returns NexusSurveyQuestion

View source

isMultiSelect

property
bool get isMultiSelect
View source

type

field
final String type

open | single_choice | multiple_choice | rating | nps | boolean | link | email

View source

id

field
final String id
View source

label

field
final String label
View source

description

field
final String? description
View source

required

field
final bool required
View source

choices

field
final List<NexusSurveyChoice> choices
View source

display

field
final String? display
View source

scaleMin

field
final int? scaleMin
View source

scaleMax

field
final int? scaleMax
View source

lowerLabel

field
final String? lowerLabel
View source

upperLabel

field
final String? upperLabel
View source

buttonText

field
final String? buttonText
View source

buttonUrl

field
final String? buttonUrl
View source

NexusSurveyTrigger

class View source

NexusSurveyTrigger

constructor
const NexusSurveyTrigger({this.events = const [], this.delaySeconds, this.minInterval, this.selector})

Parameters

Prop

Type

View source

fromJson()

static method
static NexusSurveyTrigger? fromJson(Map<String, dynamic>? m)

Parameters

Prop

Type

Returns NexusSurveyTrigger?

View source

events

field
final List<String> events
View source

delaySeconds

field
final int? delaySeconds
View source

minInterval

field
final int? minInterval
View source

selector

field
final String? selector
View source

NexusSurvey

class View source

NexusSurvey

constructor
const NexusSurvey({required this.id, required this.name, required this.type, required this.questions, this.appearance = const {}, this.trigger, this.iterationKey, this.resumeResponseId, this.resumeAnswers = const {}})

Parameters

Prop

Type

View source

fromJson()

static method
static NexusSurvey fromJson(dynamic json)

Parameters

Prop

Type

Returns NexusSurvey

View source

position

property
String? get position
View source

primaryColorHex

property
String? get primaryColorHex
View source

thankYouTitle

property
String? get thankYouTitle
View source

thankYouMessage

property
String get thankYouMessage
View source

showThankYou

property
bool get showThankYou
View source

showProgressBar

property
bool get showProgressBar
View source

submitButtonText

property
String? get submitButtonText
View source

id

field
final String id
View source

name

field
final String name
View source

type

field
final String type
View source

questions

field
final List<NexusSurveyQuestion> questions
View source

appearance

field
final Map<String, Object?> appearance
View source

trigger

field
final NexusSurveyTrigger? trigger
View source

iterationKey

field
final String? iterationKey
View source

resumeResponseId

field
final String? resumeResponseId
View source

resumeAnswers

field
final Map<String, Object?> resumeAnswers
View source

SurveySubmit

typedef
typedef SurveySubmit = Future<void> Function(NexusSurvey survey, Map<String, Object?> answers, {bool completed, bool dismissed})

Persists a response (partial or terminal). Wired to the surveys service.

View source

NexusSurveyController

class
class NexusSurveyController extends ChangeNotifier

Drives one survey: holds answers, step position, validity, and submit/dismiss.

This is the seam for custom UIs — pass your own widget to the overlay and drive it entirely from this controller (currentQuestion, setAnswer, next, back, complete, dismiss, progress). It's a ChangeNotifier, so rebuild on changes.

View source

step

property
int get step
View source

totalSteps

property
int get totalSteps
View source

isDone

property
bool get isDone
View source

isSubmitting

property
bool get isSubmitting
View source

progress

property
double get progress
View source

isLast

property
bool get isLast
View source

currentQuestion

property
NexusSurveyQuestion? get currentQuestion
View source

canAdvance

property
bool get canAdvance

Whether the current (required) question has a valid answer.

View source

survey

field
final NexusSurvey survey
View source

onClose

field
VoidCallback? onClose

Wired by the overlay to remove the survey from the screen. Call close from your UI when you're done presenting (e.g. after a thank-you).

View source

answers

field
final Map<String, Object?> answers

Answers keyed by question id (value type depends on question type).

View source

close()

method
void close()
View source

answerFor()

method
Object? answerFor(String questionId)

Parameters

Prop

Type

Returns Object?

View source

setAnswer()

method
void setAnswer(String questionId, Object? value)

Parameters

Prop

Type

View source

toggleChoice()

method
void toggleChoice(String questionId, String value)

Toggle a value within a multi-select answer.

Parameters

Prop

Type

View source

next()

method
Future<void> next()

Advance to the next question, or complete on the last.

View source

back()

method
void back()
View source

complete()

method
Future<void> complete()
View source

dismiss()

method
Future<void> dismiss()
View source

NexusQuestionBuilder

typedef
typedef NexusQuestionBuilder = Widget Function(BuildContext context, NexusSurveyController controller, NexusSurveyQuestion question)

Override the rendering of a single question. Return your own widget; read the current value with controller.answerFor(question.id) and write it with controller.setAnswer(...) / controller.toggleChoice(...).

View source

NexusSurveyView

class
class NexusSurveyView extends StatefulWidget

The built-in survey card. Renders one question at a time with progress, a thank-you screen, and default widgets per question type. Pass a questionBuilder to override individual questions, or replace the whole card via NexusSurveyOverlay(surveyBuilder: ...).

View source

NexusSurveyView

constructor
const NexusSurveyView({super.key, required this.controller, this.questionBuilder})

Parameters

Prop

Type

View source

controller

field
final NexusSurveyController controller
View source

questionBuilder

field
final NexusQuestionBuilder? questionBuilder
View source

NexusSurveyBuilder

typedef
typedef NexusSurveyBuilder = Widget Function(BuildContext context, NexusSurveyController controller)

Fully replace the survey UI. You receive the NexusSurveyController; render whatever you want and drive it (answers, next/back, complete, dismiss, close).

View source

NexusSurveyOverlay

class
class NexusSurveyOverlay extends StatefulWidget

Hosts the currently-active survey above your app. Add it via MaterialApp.builder so it has a Material/Overlay/MediaQuery ancestor:

MaterialApp(
  builder: (context, child) => NexusSurveyOverlay(child: child!),
  // ...
)

Bring your own UI with surveyBuilder (whole card) or questionBuilder (per question) — otherwise the built-in NexusSurveyView is used.

View source

NexusSurveyOverlay

constructor
const NexusSurveyOverlay({super.key, required this.child, this.surveyBuilder, this.questionBuilder})

Parameters

Prop

Type

View source

child

field
final Widget child
View source

surveyBuilder

field
final NexusSurveyBuilder? surveyBuilder
View source

questionBuilder

field
final NexusQuestionBuilder? questionBuilder
View source

On this page