claform_sdk_flutter library

Claform Flutter SDK

A complete Flutter SDK for embedding surveys with 36 question types, theming, offline support, quiz scoring, and full backend API integration.

Classes

ABTestAssignment
The result of assigning a user to an A/B test variant.
ABTestConfig
Configuration for a single A/B test.
ABTestingEngine
Deterministic hash-based A/B testing engine.
ABTestVariant
A variant in an A/B test.
AddressInput
Address input with labeled text fields.
AllQuestionsLogicResult
Aggregated logic evaluation result for all questions on a page or survey.
AnalyticsAdapter
Abstract adapter for platform-specific analytics.
AnalyticsEvent
An analytics event to be tracked.
AnalyticsTracker
Auto-tracks SDK events and batches them for submission via an AnalyticsAdapter.
AnalyticsTrackerConfig
Configuration for the analytics tracker.
ApiClient
REST API client that communicates with the NestJS survey backend.
BackgroundSyncAdapter
Abstract adapter for platform-specific background sync.
BackgroundSyncConfig
Configuration for background sync tasks.
BiometricAdapter
Abstract adapter for platform-specific biometric authentication.
BiometricAuthResult
Result of a biometric authentication attempt.
CachedMediaItem
Metadata about a cached media item.
CardSortConfig
Configuration for a card_sort question.
CardSortInput
Card sort input.
CardSortItem
A card or category item for a card_sort question.
ChoiceOption
Reusable option item widget for radio/checkbox lists.
ConflictDetail
Details about a detected conflict.
ConflictEngine
Handles sync conflict detection and resolution for offline responses.
ConflictEngineConfig
Configuration for the ConflictEngine.
ConflictResolution
The result of resolving a conflict.
ConnectivityAdapter
Abstract adapter for platform-specific connectivity monitoring.
ConnectivityInfo
Information about the current connectivity state
ConstantSumInput
Constant sum allocation input.
DateInput
Date picker input.
DateTimeInput
Combined date+time picker input.
DeepLinkConfig
Configuration for deep link parsing.
DeepLinkParser
Parses deep link URLs into structured survey configuration.
DioNetworkAdapter
NetworkAdapter implementation using the dio HTTP library.
DividerBlock
Renders a divider display block honouring the configured style ('solid' | 'dashed' | 'dotted' | 'gradient'), colour, and thickness ('thin' | 'medium' | 'thick').
DividerBlockConfig
Configuration for a divider display block.
Dropdown/modal picker with search/filter capability, clear selection button, and placeholder text.
EmailInput
Email input with email keyboard type, validation visual feedback, and placeholder text.
EmojiRatingInput
Emoji-based rating input.
EncryptedStorageAdapter
Transparent encryption wrapper around a StorageAdapter.
EncryptionAdapter
Abstract adapter for platform-specific encryption.
ErrorScreen
Error display screen shown when survey loading or submission fails.
EventBus
Event bus for SDK communication
FileUploadInput
File upload input.
FileUploadItem
File upload item in response
FileUploadOptions
File upload options
ForegroundSyncAdapter
Default BackgroundSyncAdapter that uses periodic Timers.
GeolocationAdapter
Abstract adapter for platform-specific geolocation services.
GeoLocationOptions
Options for controlling position requests.
GeoPosition
A geographic position with coordinates and optional accuracy metadata.
HeadingBlock
Renders a heading display block as a styled, non-answerable title.
HeadingBlockConfig
Configuration for a heading display block.
I18nManager
Manages translations, locale selection, and RTL detection for the survey SDK.
ImageBlock
Renders an image_block display block.
ImageBlockConfig
Configuration for an image_block display block.
ImageChoiceInput
Image-based choice selection with grid layout.
ImageHeatmapConfig
Configuration for an image_heatmap question.
ImageHeatmapInput
Image heatmap input.
LoadingScreen
Loading indicator screen displayed while the survey is being fetched.
LocationInput
Location/address input with 5 text fields (address, city, state, country, postal code) and optional GPS button for lat/lng. Outputs LocationResponseValue.
LocationResponseValue
Location response value
LogicCondition
Logic condition for conditional display/skip
LogicEngine
Pure Dart engine for evaluating conditional display logic, skip logic, and requirement overrides on survey questions.
LogicEvaluationResult
Result of evaluating display logic for a single question.
LogicRule
Logic rule with conditions and action
MatrixColumn
Matrix column definition
MatrixMultiInput
Matrix with multi-choice per row (checkboxes).
MatrixRow
Matrix row definition
MatrixSingleInput
Matrix with single choice per row (radio buttons).
MaxDiffInput
MaxDiff (best/worst scaling) input.
MaxDiffSetResponse
MaxDiff set response value
MediaCache
Downloads and caches survey media assets for offline use.
MediaUploadItem
An item queued for media upload when connectivity is restored.
MemoryStorageAdapter
In-memory storage adapter for testing and fallback
MultiChoiceInput
Multiple selection from a list of options.
MultiChoiceResponse
Multi choice response with optional "other" text
NameInput
Full-name input with labeled text fields.
Navigation buttons row: Previous, Next, and Submit.
NetworkAdapter
Abstract network adapter for platform-specific HTTP
NetworkRequestOptions
Network request options
NetworkResponse<T>
Network response wrapper
NoOpAnalyticsAdapter
No-op analytics adapter for testing or when analytics is disabled.
NpsInput
Net Promoter Score (0-10) input.
NumberInput
Number input with numeric keyboard, decimal support, and min/max value display.
OfflineDeviceInfo
OfflineLocation
OfflineManager
Manages offline response queuing, survey caching, and sync with the server.
OfflinePackageConfig
Offline package configuration
OfflineResponse
Offline response queued for sync
OfflineResponseMetadata
Metadata for offline responses
OfflineSyncInfo
Sync tracking information for offline responses
OfflineValidationError
OfflineValidationResult
OfflineValidationWarning
OpinionScaleInput
Opinion scale input with button row, endpoint labels (left/right), optional middle label, and theme colors.
PackageData
Data contained within an offline package.
PackageInfo
Metadata about a downloaded offline package.
PackageManager
Downloads, verifies, and loads offline survey packages.
Page
Survey page containing questions
PageRandomizationConfig
Page randomization configuration
PageTransition
Animated page transitions for survey navigation.
A parsed deep link containing survey identification and context.
PaymentAdapter
Abstract adapter for platform-specific payment processing.
PaymentAmount
Amount to charge, expressed in the smallest currency unit.
PaymentHandler
Orchestrates payment flows within surveys.
PaymentQuestion
Payment details for a survey question that requires payment.
PaymentRequest
Request to process a payment.
PaymentResult
Result of a payment operation.
PhoneInput
Phone number input with phone keyboard type, formatting, and optional country code prefix.
PhotoUploadInput
Photo upload input with camera and gallery options.
PipingEngine
Pure Dart engine for resolving piped text (variable substitution tokens) embedded in survey content such as question text, descriptions, and labels.
PollingConnectivityAdapter
Default ConnectivityAdapter that uses periodic HTTP HEAD pings to determine connectivity.
PollingConnectivityConfig
Configuration for the polling-based connectivity checker.
PriceSensitivityConfig
Configuration for a price_sensitivity (Van Westendorp) question.
PriceSensitivityInput
Van Westendorp Price Sensitivity Meter input.
ProgressBar
Survey progress indicator with multiple display variants.
ProgressInfo
Progress information
PushNotificationAdapter
Abstract adapter for platform-specific push notifications.
PushNotificationPayload
Payload for a push notification.
Question
Main question model matching backend Question entity
QuestionInputProps
Props shared by all question input widgets.
QuestionLogic
Question logic configuration
QuestionOption
Question option for choice/ranking/matrix questions
QuestionRenderer
Factory widget that maps QuestionType to the correct input widget.
QuestionResponse
A single question's answer in a response submission
QuestionResult
Quiz question result
QuestionSettings
Type-specific question settings stored in the settings JSON field
QuestionWrapper
Wrapper widget that renders question title, description, required indicator, child content, and validation errors in a consistent layout.
QuizEngine
Pure Dart engine for scoring quiz questions and computing overall quiz results.
QuizFeedback
Post-answer feedback widget for quiz questions.
QuizHint
Progressive hint reveal widget for quiz questions.
QuizResult
Quiz result returned after quiz submission
QuizResultScreen
Quiz results display screen.
QuizSettings
Quiz-specific settings
QuizTimer
Countdown timer for timed quizzes.
RandomizationConfig
Randomization configuration for question options
RandomizationEngine
Pure Dart engine for deterministic option randomization using a seeded PRNG.
RankingInput
Drag-to-rank input using ReorderableListView.
RatingScaleInput
Numeric scale rating (e.g., 1-5, 1-10).
RepeatingGroupConfig
Configuration for a repeating_group question.
RepeatingGroupField
A single sub-field within a repeating_group row.
RepeatingGroupInput
Repeating group input.
ResolvedAnimations
Resolved animation configuration.
ResolvedBackground
Resolved background configuration.
ResolvedBranding
Resolved branding configuration.
ResolvedColors
Fully resolved color palette with defaults for every token.
ResolvedFonts
Resolved font configuration with sensible defaults.
ResolvedLayout
Resolved layout configuration.
ResolvedProgress
Resolved progress bar configuration.
ResolvedSpacing
Resolved spacing configuration.
ResolvedTheme
The fully resolved theme with every field guaranteed to have a value.
ResponseMetadata
Response metadata sent with submissions
RetryConfig
Retry configuration for network requests
ScrollToError
Utility to auto-scroll to the first validation error.
SdkEvent
Event data wrapper
SemanticDifferentialInput
Bipolar/semantic differential scale.
SessionData
Persistent session data for saving and resuming survey progress.
SessionManager
Manages survey session persistence and auto-save.
ShakeAnimation
Shake animation wrapper for invalid inputs.
ShakeAnimationState
SharedPrefsStorageAdapter
StorageAdapter implementation backed by the shared_preferences package.
SignatureInput
Signature pad input.
SingleChoiceInput
Single selection from a list of options.
SingleChoiceResponse
Single choice response with optional "other" text
SkipTarget
Describes a skip destination triggered by logic evaluation.
SliderInput
Slider input with min/max labels, current value display, step support, and theme colors.
SpacerBlock
Renders a spacer display block as vertical empty space.
SpacerBlockConfig
Configuration for a spacer display block.
StarRatingInput
Star rating input with configurable star count, half-star support, 4 size presets, and custom active/inactive colors.
StorageAdapter
Abstract storage adapter for platform-specific persistence
Survey
Main survey model matching backend Survey entity
SurveyLanguageSettings
Language settings for a survey
SurveyNotifier
Flutter ChangeNotifier that wraps SurveySDK and provides reactive state management for survey-taking UI.
SurveyPageRenderer
Renders all visible questions for the current survey page.
SurveyResponse
Full survey response from backend
SurveyScope
A convenience widget that sets up both SurveyNotifier and SurveyThemeNotifier using MultiProvider.
SurveyScreen
Main batteries-included survey screen widget.
SurveySDK
Main SurveySDK class that orchestrates all engines and services.
SurveySDKConfig
SDK configuration matching TypeScript SurveySDKConfig
SurveySettings
Survey settings
SurveySpacing
Standard spacing scale used throughout the survey SDK.
SurveyState
Immutable survey state snapshot
SurveyStateManager
Manages survey state transitions with event emission
SurveyThemeData
Survey-specific theme extension data carried on ThemeData.
SurveyThemeNotifier
ChangeNotifier that holds and exposes the resolved survey theme.
SurveyTranslation
A single translation entry
SwipeNavigator
Gesture-based page navigation wrapper.
TextBlock
Renders a text_block display block as a paragraph of body copy.
TextBlockConfig
Configuration for a text_block display block.
TextLongInput
Multi-line text input with configurable minLines/maxLines, character counter, focus/error states, and theme-aware styling.
TextShortInput
Single-line text input with focus state tracking, error state, placeholder text, character limit, and theme-aware styling.
ThankYouPageSettings
Thank you page configuration
ThankYouScreen
Post-submission thank you screen.
ThemeAnimations
ThemeBackground
ThemeBranding
ThemeColors
ThemeEngine
Pure Dart theme resolution engine.
ThemeLayout
ThemeProgress
ThemeSettings
Theme settings matching backend ThemeSettings
ThemeSpacing
ThemeTypography
TimeInput
Time picker input.
ValidationEngine
Pure Dart validation engine that checks answers for all 31 question types.
ValidationError
Inline validation error message display.
ValidationResult
The outcome of validating a single answer.
ValidationRule
Validation rules for a question
VideoEmbedBlock
Renders a video_embed display block as a tappable card.
VideoEmbedConfig
Configuration for a video_embed display block.
WebsiteUrlInput
URL input with URL keyboard type and http/https prefix hint.
YesNoInput
Yes/No toggle input.

Enums

BiometricType
Types of biometric authentication available on the device.
ConflictStrategy
Strategy for resolving sync conflicts between client and server data.
ConnectivityStatus
Connectivity status values
FormType
Form type matching backend FormType
HapticType
Categories of haptic feedback matching common mobile interaction patterns.
MediaUploadStatus
Status of a queued media upload.
OfflineSyncStatus
Offline sync status
PaymentStatus
Status of a payment transaction.
QuestionType
All backend QuestionType values.
ResponseStatus
Response status matching backend ResponseStatus
SdkEventType
All SDK event types matching TypeScript SurveySDKEvents
SupportedLanguage
Supported language codes
SurveyPhase
Survey lifecycle phases (state machine)
SurveyStatus
Survey status enum matching backend SurveyStatus
TranslationContentType
Content types that can be translated
TranslationStatus
Translation status

Extensions

SurveyThemeBuildContext on BuildContext
Convenience extension to retrieve SurveyThemeData from a BuildContext.
SurveyThemeExtension on ThemeData
Convenience extension to retrieve SurveyThemeData from a ThemeData.

Constants

actionElementTypes → const Set<QuestionType>
Action element types. These represent server-side side effects (redirect, email, webhook, scoring, payment, etc.) and are never rendered as input.
defaultAnalyticsTrackerConfig → const AnalyticsTrackerConfig
Default analytics tracker configuration.
defaultBackgroundSyncConfig → const BackgroundSyncConfig
Default background sync configuration.
displayBlockTypes → const Set<QuestionType>
Display/content block types. These render static content and never collect an answer.
rtlLanguages → const Set<String>
RTL languages set
validTransitions → const Map<SurveyPhase, Set<SurveyPhase>>
Valid state transitions

Properties

isAndroid bool
Returns true when running on Android.
no setter
isDesktop bool
Returns true when running on a desktop platform (macOS, Windows, Linux).
no setter
isIOS bool
Returns true when running on iOS.
no setter
isLinux bool
Returns true when running on Linux.
no setter
isMacOS bool
Returns true when running on macOS.
no setter
isMobile bool
Returns true when running on a mobile platform (iOS or Android).
no setter
isWeb bool
Returns true when running on the web (compiled with dart2js / dart2wasm).
no setter
isWindows bool
Returns true when running on Windows.
no setter

Functions

announceForAccessibility(BuildContext context, String message) → void
Announces message to active screen readers via the Flutter semantics system.
blockAlignment(String? alignment) Alignment
Maps a content-block alignment string to a horizontal Alignment.
blockCrossAxisAlignment(String? alignment) CrossAxisAlignment
Maps a content-block alignment string to a CrossAxisAlignment for use in a Column.
blockTextAlign(String? alignment) TextAlign
Maps a content-block alignment string to a TextAlign.
colorToHex(Color color) String
Converts a Flutter Color to a hex string in #RRGGBB format.
createBodyStyle(ResolvedTheme theme) TextStyle
Creates a TextStyle for body text.
createCaptionStyle(ResolvedTheme theme) TextStyle
Creates a TextStyle for captions (smallest readable text).
createErrorStyle(ResolvedTheme theme) TextStyle
Creates a TextStyle for validation error messages.
createHeadingStyle(ResolvedTheme theme, {int level = 1}) TextStyle
Creates a TextStyle for headings at the specified level (1-4).
createLabelStyle(ResolvedTheme theme) TextStyle
Creates a TextStyle for labels (slightly smaller than body text).
createSurveyThemeData(ResolvedTheme theme) ThemeData
Creates a complete Flutter ThemeData from a ResolvedTheme.
darken(Color color, double amount) Color
Darkens color by mixing it with black.
focusAndAnnounce(BuildContext context, FocusNode focusNode, String message) → void
Requests focus on the given FocusNode and announces message to screen readers.
getBottomSafeArea(BuildContext context) double
Returns the bottom safe area inset, which is useful for bottom-pinned buttons on devices with home indicators.
getContrastColor(Color background) Color
Returns either black or white, whichever has better contrast against the given background color.
getHeadingSize(int level, ResolvedTheme theme) double
Returns the font size for a heading at the given level (1-4) using the theme's heading scale.
getKeyboardHeight(BuildContext context) double
Returns the height of the visible software keyboard, or 0 if hidden.
getLineHeight(double fontSize, ResolvedTheme theme) double
Computes the line height (in logical pixels) for a given fontSize.
getNpsColor(int score) Color
Returns the appropriate color for an NPS (Net Promoter Score) value.
getOptionSemanticsProps(String label, {bool isSelected = false, bool isRadio = true, int index = 0, int total = 0}) SemanticsProperties
Returns SemanticsProperties for a selectable option (radio or checkbox).
getQuestionSemanticsProps(Question question, {bool isRequired = false, List<String> errors = const []}) SemanticsProperties
Returns SemanticsProperties appropriate for a survey question widget.
getSafeAreaPadding(BuildContext context) EdgeInsets
Returns the EdgeInsets for the device safe area (notch, home indicator, status bar).
getScreenDimensions(BuildContext context) Size
Returns the physical screen dimensions (window size * device pixel ratio).
getSliderSemanticsProps(double value, double min, double max, String label) SemanticsProperties
Returns SemanticsProperties for a slider / adjustable control.
getTopSafeArea(BuildContext context) double
Returns the top safe area inset (status bar height).
getWindowDimensions(BuildContext context) Size
Returns the current logical window dimensions.
hapticButtonPress() → void
Triggers haptic feedback for a button press.
hapticError() → void
Triggers haptic feedback for a validation error.
hapticPageChange() → void
Triggers haptic feedback for page navigation.
hapticSelection() → void
Triggers a light haptic tap, suitable for option selection or toggle.
hapticSuccess() → void
Triggers haptic feedback for a successful action.
hapticWarning() → void
Triggers haptic feedback for a warning.
hexToColor(String? hex, [Color fallback = const Color(0xFF000000)]) Color
Parses a CSS hex color string to a Flutter Color.
horizontalGap(BuildContext context, double value) SizedBox
Returns a SizedBox with responsive width.
isActionElement(QuestionType type) bool
Whether type is an action element (redirect/email/webhook/calculate/ score_display/payment/integration). Action elements never render as input.
isDisplayBlock(QuestionType type) bool
Whether type is a display/content block (heading, text, image, video, divider, spacer). Display blocks are visible but never answerable.
isInputQuestion(QuestionType type) bool
Whether type is an answerable input question (i.e. neither a display block nor an action element, and not the QuestionType.unknown sentinel). Only input questions count toward validation, progress, required gating, answers, and quiz scoring.
isKeyboardVisible(BuildContext context) bool
Returns true if the software keyboard is currently visible.
isLandscape(BuildContext context) bool
Returns true when the device is in landscape orientation.
isPhone(BuildContext context) bool
Returns true when the device's shortest screen dimension is <= 600 logical pixels (i.e. a phone-sized device).
isPortrait(BuildContext context) bool
Returns true when the device is in portrait orientation.
isScreenReaderActive(BuildContext context) bool
Synchronous check for screen reader status from a BuildContext.
isScreenReaderEnabled() Future<bool>
Returns true if a screen reader (e.g. TalkBack, VoiceOver) is currently active on the device.
isTablet(BuildContext context) bool
Returns true when the device's shortest screen dimension exceeds 600 logical pixels, which is the standard Material Design tablet breakpoint.
lerpDouble(double a, double b, double t) double?
Helper to linearly interpolate between two doubles.
lighten(Color color, double amount) Color
Lightens color by mixing it with white.
maxContentWidth(BuildContext context, {double maxWidth = 640}) double
Returns the maximum content width, clamped to a readable measure.
moderateScale(BuildContext context, double value, [double factor = 0.5]) double
Applies a moderate scale that blends the raw value with the width-scaled value using the given factor (default 0.5).
parseColor(String? hex, [Color fallback = const Color(0xFF000000)]) Color
Parses a hex color string to a Flutter Color.
parseHexColor(String? input, [Color fallback = const Color(0xFF000000)]) Color
Parses a color string (hex or rgba) into a Color.
parseQuestionType(String value) QuestionType
Maps snake_case API strings to QuestionType enum
platformSelect<T>({required T ios, required T android, T? web}) → T
Returns a value chosen based on the current platform.
platformSelectAll<T>({required T mobile, T? tablet, T? desktop, T? web}) → T
Extended platform selector that also supports desktop targets.
questionTypeToString(QuestionType type) String
Converts QuestionType enum to snake_case API string
responsivePadding(BuildContext context, {double horizontal = SurveySpacing.md, double vertical = SurveySpacing.md, double factor = 0.5}) EdgeInsets
Creates padding that adapts to the screen width via moderateScale.
roundToPixel(BuildContext context, double value) double
Rounds value to the nearest physical pixel boundary using the device pixel ratio, preventing sub-pixel rendering artifacts.
roundToPixelRaw(double value, double devicePixelRatio) double
Overload that accepts a raw device pixel ratio for cases where a BuildContext is not available.
scale(BuildContext context, double value) double
Scales value proportionally to the device screen width relative to the _baseWidth baseline.
scaleFontSize(double baseSize, double scale) double
Scales a base font size by the given scale factor.
semanticRoleForQuestionType(QuestionType type) String
Maps a QuestionType to the most appropriate semantic description for screen readers.
surveyPadding({double horizontal = SurveySpacing.md, double vertical = SurveySpacing.md}) EdgeInsets
Creates symmetric horizontal and vertical padding using the survey spacing scale.
triggerHaptic(HapticType type) → void
Triggers device haptic feedback of the given type.
verticalGap(BuildContext context, double value) SizedBox
Returns a SizedBox with responsive height.
verticalScale(BuildContext context, double value) double
Scales value proportionally to the device screen height relative to the _baseHeight baseline.
withOpacity(Color color, double opacity) Color
Returns a new Color with the given opacity (alpha value).

Typedefs

BackgroundSyncTask = Future<void> Function()
A function that performs background sync work.
ConnectivityChangeHandler = void Function(ConnectivityInfo info)
Handler invoked when connectivity changes
DisplayBlockBuilder = Widget Function({required Question question, required ResolvedTheme theme})
Type definition for a display/content block widget builder.
EventHandler = void Function(Map<String, dynamic> data)
Type-safe event handler
ManualConflictHandler = Future<ConflictResolution> Function(ConflictDetail conflict)
Handler for manual conflict resolution.
MediaCacheEventHandler = void Function(String event, Map<String, dynamic> data)
Handler for media cache events.
PaymentStatusHandler = void Function(String paymentId, PaymentStatus status)
Handler invoked when a payment status changes.
PushNotificationHandler = void Function(PushNotificationPayload payload)
Handler invoked when a push notification is received or tapped.
QuestionInputBuilder = Widget Function({required bool disabled, required List<String>? errors, required ValueChanged onChange, required Question question, required ResolvedTheme theme, required dynamic value})
Type definition for a question input widget builder.

Exceptions / Errors

SdkError
SDK error with code and optional details