SDKInstance class

Internal singleton that backs the public Digia static facade.

This is an implementation detail of the SDK. App developers never see or reference this class — all calls flow through Digia.

Implemented types
Mixed-in types

Properties

allCampaigns → List<CampaignModel>
All campaigns currently cached in the store. Exposed for host/dev tooling (e.g. the medihub "campaign lab" screen) to enumerate fetched campaigns.
no setter
analyticsQueueForTesting → SqliteAnalyticsQueue?
no setter
anchorRegistry → AnchorRegistry
no setter
campaignFetchForTesting → Future<void>
Completes when the campaign fetch started by initialize has settled the SDK state (ready or failed). Tests await it instead of guessing.
no setter
captureBubbleHiddenNotifier → ValueNotifier<bool>
final
captureFlashNotifier → ValueNotifier<int>
final
captureMediaNotifier → ValueNotifier<bool>
final
captureModeNotifier → ValueNotifier<bool>
Capture controls are debug-only and independent from Sync.
final
captureStructureNotifier → ValueNotifier<bool>
final
captureTextNotifier → ValueNotifier<bool>
final
clockForTesting ↔ int Function()?
Replaces the session clock (epoch milliseconds) in tests, so a test can simulate a day. Null, the default, keeps the system clock.
getter/setter pair
controller → DigiaOverlayController
Controller for inline campaigns, notifies when they change. Exposed so DigiaHost can subscribe at mount time.
no setter
currentScreen → String?
no setter
events → EngageEventEmitter
Experience-event emitter used by render surfaces (DigiaSlot, DigiaHost, nudge widgets) to route lifecycle events to CEP and/or Digia.
no setter
floaterStoryOrchestrator → FloaterStoryOrchestrator
no setter
floaterStoryReporter → FloaterStoryReporter
no setter
gamificationChances → Map<String, ChanceGranted>
The granted chance per campaign key, for the slot and the overlay.
no setter
gamificationEntries → ChangeNotifier
Gamification entry surface: inline teasers and floating entries. DigiaHost owns the floating overlay and DigiaSlot renders the inline teaser in digia_rewards_widget against this; the app needs no new setup. Exposed as a Listenable so both hosts rebuild on show/hide without polling.
no setter
gamificationEntryCampaigns → Map<String, CampaignModel>
The campaign behind each shown entry, for the slot and the overlay.
no setter
gamificationEntryPayloads → Map<String, CEPTriggerPayload>
The trigger payload behind each shown entry, for entry taps.
no setter
guideManager → GuideShowcaseManager
no setter
guideOrchestrator → GuideOrchestrator
no setter
hashCode → int
The hash code for this object.
no setterinherited
inlineReporter → InlineReporter
no setter
isReady → bool
Whether core is READY, so deliver routes instead of dropping.
no setteroverride
no setter
networkClientFactoryForTesting ↔ NetworkClientFactory?
Replaces the SDK's network client in tests. The production client is a DioNetworkClient that owns its whole engine configuration.
getter/setter pair
nudgeOrchestrator → NudgeOrchestrator
no setter
pipOrchestrator → PipOrchestrator
no setter
pipReporter → PipReporter
no setter
presentations → PresentationCoordinator
Internal accessor for tests and host tooling. Never app-facing.
no setter
rewardsResponse → GameRewardsResponse?
The latest getRewards answer, driving the rewards page and widget. Null until the first fetch; a failed fetch keeps the previous one.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sdkConfigFetchForTesting → Future<void>
no setter
sdkState → SDKState
no setter
servicesListenable → ValueListenable<SDKServices?>
Changes whenever the services are assigned or replaced, so a widget built before initialize finished picks them up when they appear.
no setter
servicesOrNull → SDKServices?
Core SDK services, or null until initialize has built them.
no setter
storyReporter → StoryReporter
no setter
successfulCapturePagesNotifier → ValueNotifier<List<String>>
final
surveyOrchestrator → SurveyOrchestrator
no setter
surveyReporter → SurveyReporter
no setter
themeMode → DigiaThemeMode
no setter
waitClockForTesting ↔ int Function()?
Replaces _sleepClock in tests, where timers run on fake time.
getter/setter pair

Methods

anchorExposed(String anchorKey) → void
Called by DigiaAnchor each time the anchor becomes exposed (see SlotExposure): every return to its screen or scroll into view is an appearance, so the signal is not deduplicated.
attachNavigator(NavigatorState navigator) → void
bindSurveyProgress(int token, ({int? abandonedAtItem, int? answeredCount}) read()?) → void
campaignForPayload(CEPTriggerPayload payload) → CampaignModel?
Looks up the campaign for payload (live test entry if present, else the real cache). Used by inline surfaces to attach campaign context.
captureCurrentPage(TextDirection textDirection) → Future<String>
clearAllInlineContent() → void
Clears all inline content (carousels/stories) across every placement.
clearInlineContent(List<String> placementKeys) → void
Clears inline content (carousels/stories) for each key in placementKeys. Once loaded, inline content is retained indefinitely — hosts should call this on logout so a stale user's content doesn't linger across the account switch. No-op if placementKeys is empty. The app removes it, so it is reported cancelled, not as a user close.
clearUserId() → Future<void>
deliver(CEPTriggerPayload trigger) → CampaignPresentation
Delivers a CEP trigger into the Digia engine.
override
didChangeAccessibilityFeatures() → void
Called when the system changes the set of currently active accessibility features.
inherited
didChangeAppLifecycleState(AppLifecycleState state) → void
Called when the system puts the app in the background or returns the app to the foreground.
override
didChangeLocales(List<Locale>? locales) → void
Called when the system tells the app that the user's locale has changed. For example, if the user changes the system language settings.
inherited
didChangeMetrics() → void
Called when the application's dimensions change. For example, when a phone is rotated.
inherited
didChangePlatformBrightness() → void
Called when the platform brightness changes.
inherited
didChangeTextScaleFactor() → void
Called when the platform's text scale factor changes.
inherited
didChangeViewFocus(ViewFocusEvent event) → void
Called whenever the PlatformDispatcher receives a notification that the focus state on a view has changed.
inherited
didHaveMemoryPressure() → void
Called when the system is running low on memory.
inherited
didPopRoute() → Future<bool>
Called when the system tells the app to pop the current route, such as after a system back button press or back gesture.
inherited
didPushRoute(String route) → Future<bool>
Called when the host tells the application to push a new route onto the navigator.
inherited
didPushRouteInformation(RouteInformation routeInformation) → Future<bool>
Called when the host tells the application to push a new RouteInformation and a restoration state onto the router.
inherited
didRequestAppExit() → Future<AppExitResponse>
Called when a request is received from the system to exit the application.
inherited
dwellElapsedMs(String cepCampaignId) → int?
Milliseconds since cepCampaignId's surface was marked visible, for callers that must stamp time_to_action_ms at the moment of the tap rather than when they get around to reporting it.
failNudgePresentation(CEPTriggerPayload payload, DropReason reason, String detail, {Object? error}) → void
A nudge DigiaHost could not present (no navigator, or the present threw): nothing reached the screen, so it leaves the surface and settles as a drop now rather than blocking every later campaign.
floaterStoryActionScope(BuildContext context) → EngageActionScope
Action bindings for content inside a story floater.
flushAnalytics() → Future<void>
getAnonymousId() → String
handleCancelBackGesture() → void
Called when a predictive back gesture is canceled, indicating that no navigation should occur.
inherited
handleCommitBackGesture() → void
Called when a predictive back gesture is finished successfully, indicating that the current route should be popped.
inherited
handleLiveTestCampaign(LiveTestInvocation invocation) → void
Handles one campaign_test SSE event: ACKs received, then routes the campaign through the same CampaignRouter an organic CEP trigger uses, with the live-test driver.
handleStartBackGesture(PredictiveBackEvent backEvent) → bool
Called at the start of a predictive back gesture.
inherited
handleStatusBarTap() → void
Called when the user taps the status bar on iOS, to scroll a scroll view to the top.
inherited
handleUpdateBackGestureProgress(PredictiveBackEvent backEvent) → void
Called when a predictive back gesture moves.
inherited
initialize(DigiaConfig config) → Future<void>
Returns when the campaign fetch has settled the SDK state (ready or failed) or _initializeCap after the call, whichever comes first. Never throws: a failure leaves the SDK in SDKState.failed.
isGamificationEntryHidden(String campaignKey) → bool
Whether a floating campaign key is hidden for this session.
loadRewardsAsync() → Future<GameRewardsResponse?>
refreshRewards as a result, for the rewards screen. Null with no user or on a failed fetch. Never throws.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onHostMounted() → void
Called by DigiaHost when it mounts into the widget tree.
onHostUnmounted() → void
Called by DigiaHost when it is removed from the widget tree.
openDebugSettingsFromOverlay() → Future<void>
Pushes the debug settings screen from DigiaRecordingBadge, which lives above the app's own Navigator (inside DigiaHost's Stack, same as _presentNudge) — so it can't resolve Navigator.of(context) from its own BuildContext and must go through _navigator directly instead of the BuildContext-based Digia.openDebugSettings.
openGameForChance(String chanceId, {String? campaignId}) → Future<void>
Opens the game for a rewards chance the user already holds: the chance plays directly, never a new grantChance. Anything missing (no chance, unknown campaign, no config) is a quiet no-op, like a denied entry tap; a game already open fails with game_open_failed(busy). Completes when the game closes. Never throws.
openRewards() → void
Opens the rewards page: waiting chances and won rewards, shown full screen over the app. The page URL resolves from getRewards (at most 4 s), else the environment default. A game still loading (or on screen) would otherwise end up behind the page and block the games opened from it, so it closes first as superseded. The page refreshes on appear and after every game close. Below the OS floor it is a no-op. Never throws.
pipActionScope(BuildContext context) → EngageActionScope
Action bindings for buttons inside the expanded PiP content.
pushDebugSettingsRoute(NavigatorState navigator) → Future<void>
Pushes the debug settings screen, at most one at a time.
recordAnchorSeen(String anchorKey) → void
Called by DigiaAnchor each time an anchor key mounts. Records it against the current screen (see setCurrentScreen); one mounted before any screen is set is buffered until a screen is.
recordSlotSeen(String placementKey) → void
Called by DigiaSlot each time a placement key mounts.
refreshRewards() → Future<void>
Fetches getRewards for the rewards page and widget. Calls coalesce while one is in flight; a failure keeps the last response. Never throws.
register(DigiaCEPPlugin plugin) → void
reportAnchorlessGuideFailure(int guideToken, DiagnosticReason code, String message, {Map<String, Object> dropDetail = const {}}) → void
resetForTesting({SDKServices? services}) → void
resolveActiveCampaign() → CampaignModel?
Resolves the CampaignModel for the active payload so DigiaHost can switch on its config type and present the correct experience. Returns null (and auto-dismisses) when no matching campaign is found.
setCampaignsSuppressed(bool suppressed) → void
Suppresses overlay campaigns while the host app shows UI of its own — typically its own modal — that a campaign must not cover. See Digia.setCampaignsSuppressed.
setCaptureModeEnabled(bool enabled) → Future<void>
setCaptureProfile({bool? includeText, bool? includeImagesAndMedia, bool? includeOtherStructuralNodes}) → Future<void>
setCurrentScreen(String name) → void
Sets the current screen. This is the single source of truth for screen scoping — a PiP belongs to the screen named here when it opened, and ends when this reports a different one. That is the expected end of most PiP impressions, not an error path.
setCustomKVHandler(FutureOr<void> handler(Map<String, String> payload)?) → void
setDeepLinkHandler(FutureOr<void> handler(String deepLink)?) → void
setOpenURLHandler(FutureOr<void> handler(String deepLink)?) → void
setServicesForTesting(SDKServices services) → void
setThemeMode(DigiaThemeMode themeMode) → void
Selects the theme used when Campaign Canvas colors are rendered.
setUserAttributes(Map<String, dynamic> attributes) → Future<void>
Supplies attributes about the current user, for campaigns to interpolate.
setUserId(String userId, {String? userHash}) → Future<void>
Buffered until the services exist — not merely until initialize has been called: a host's unawaited initialize() followed by setUserId() lands while they are still being built (review B6).
slotExposed(String placementKey) → void
Called by DigiaSlot each time the slot becomes exposed; as anchorExposed.
toString() → String
A string representation of this object.
inherited
trackEvent(String eventName, {Map<String, Object?> properties = const {}}) → Future<void>
Records an event the app performed, such as a purchase.
triggerCampaign(String campaignKey, {Map<String, String>? variables}) → CampaignPresentation
Delivers a campaign the host app asked for by key, with no CEP involved — parity with Android/iOS triggerCampaign. Digia-internal: not on the public Digia API. Mints a host:<uuid> id, since no CEP supplies one.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

idGenerator ↔ String Function()
Mints presentation ids.
getter/setter pair
instance → SDKInstance
Internal accessor used only by Digia and DigiaHost.
no setter