In-app messages
In-app messages in the Flutter SDK.
import 'package:nexus_flutter/nexus.dart';| Symbol | Kind | Summary |
|---|---|---|
NexusInApp | class | In-app messages (OneSignal-style). |
NexusInAppAction | class | Emitted when a user taps a button on an in-app message. |
NexusInAppButton | class | A button on an in-app message. |
NexusInAppMessage | class | An in-app message the SDK can display (modal / banner / center / fullscreen). |
NexusInAppDesign | class | The designed look of an in-app message — built in the Nexus console's designer and delivered as content.design. |
NexusInAppFrame | class | |
NexusInAppClose | class | |
NexusInAppTap | class | What tapping an image does. |
NexusInAppBlock | sealed class | One block of a designed message. |
NexusInAppImageBlock | class | |
NexusInAppBadgeBlock | class | |
NexusInAppHeadingBlock | class | |
NexusInAppTextBlock | class | |
NexusInAppButtonsBlock | class | |
NexusInAppCarouselBlock | class | A swipeable row of up to 10 cards. |
NexusInAppCarouselCard | class | |
NexusInAppSpacerBlock | class | |
NexusInAppDividerBlock | class | |
NexusInAppDesignButton | class | |
NexusInAppView | class | Default rendering for an in-app message. |
NexusInAppDesignedView | class | Renders a message designed in the Nexus console: backdrop, placement for the layout, entrance animation, auto-dismiss, and the block stack. |
NexusInAppBuilder | typedef | Bring your own in-app message UI. |
NexusInAppOverlay | class | Hosts the currently-active in-app message above your app. |
NexusInApp
classIn-app messages (OneSignal-style). Fetches the messages meant for this user —
the server applies the audience, assigns the A/B variant and fills in
{{variables}} — then evaluates triggers (session start / custom event) and
frequency caps locally, requests display, and reports impressions/clicks.
Rendering is done by NexusInAppOverlay (default UI) or your own widget
driven by current.
active
propertyList<NexusInAppMessage> get activeAll active in-app messages for the tenant.
View sourcecurrent
fieldfinal ValueNotifier<NexusInAppMessage?> currentThe message currently requested to display (null when none). The overlay listens to this.
View sourceonAction
fieldvoid Function(NexusInAppAction action)? onActionCalled when a user taps a button (handle url / event actions yourself,
e.g. navigate or launchUrl). Event-action buttons are also auto-tracked.
onTrackEvent
fieldvoid Function(String event)? onTrackEventWired by the SDK to the analytics track() for event-action buttons.
setProperties()
methodFuture<void> setProperties(Map<String, Object?> properties, {bool refetch = true})Properties for audience targeting and personalisation, on top of the
identify traits: setProperties({'plan': 'pro', 'coupon': 'SARA20'})
matches the console's plan conditions and fills {{coupon}}. Kept for
this launch; pass refetch: false to wait for the next fetch.
Parameters
Prop
Type
clearProperties()
methodvoid clearProperties([Iterable<String>? keys])Remove properties set with setProperties.
Parameters
Prop
Type
attachRealtime()
methodvoid attachRealtime(NexusRealtime realtime)Wired by the SDK so a registered test device gets console tests instantly.
Parameters
Prop
Type
fetch()
methodFuture<List<NexusInAppMessage>> fetch()Fetch the active messages; on success, auto-show a session-start message.
Returns Future<List<NexusInAppMessage>>
onEvent()
methodvoid onEvent(String name)Called when an analytics event fires — shows a message triggered by it.
Parameters
Prop
Type
show()
methodvoid show(NexusInAppMessage m)Show a specific message now (bypasses trigger, still respects frequency).
Parameters
Prop
Type
tapButton()
methodvoid tapButton(NexusInAppMessage m, NexusInAppButton b)Handle a button tap: report the click, surface the action, auto-track
event actions, copy copy values, then dismiss. Tappable images in a
designed message come through here too, with the image block's id.
Parameters
Prop
Type
dismiss()
methodvoid dismiss(NexusInAppMessage m)Dismiss the current message (X / backdrop tap).
Parameters
Prop
Type
close()
methodvoid close()Clear the message from the screen.
View sourcedispose()
methodvoid dispose()NexusInAppAction
classEmitted when a user taps a button on an in-app message.
View sourceNexusInAppAction
constructorconst NexusInAppAction({required this.messageId, required this.buttonId, required this.action, this.url, this.event, this.value, this.variantId})Parameters
Prop
Type
messageId
fieldfinal String messageIdvariantId
fieldfinal String? variantIdThe A/B variant the tap happened in, if any.
View sourcebuttonId
fieldfinal String buttonIdaction
fieldfinal String actiondismiss | url | event | copy.
url
fieldfinal String? urlevent
fieldfinal String? eventvalue
fieldfinal String? valueFor copy: the text that was put on the clipboard.
NexusInAppButton
classA button on an in-app message.
View sourceNexusInAppButton
constructorconst NexusInAppButton({required this.id, required this.text, required this.action, this.url, this.event, this.style, this.value})Parameters
Prop
Type
NexusInAppButton.fromJson
factoryNexusInAppButton.fromJson(Map<String, dynamic> j)Parameters
Prop
Type
id
fieldfinal String idtext
fieldfinal String textaction
fieldfinal String actiondismiss | url | event | copy (designed messages only).
url
fieldfinal String? urlevent
fieldfinal String? eventvalue
fieldfinal String? valueFor copy: the text to put on the clipboard.
style
fieldfinal String? styleprimary | secondary | text.
NexusInAppMessage
classAn in-app message the SDK can display (modal / banner / center / fullscreen).
View sourceNexusInAppMessage
constructorconst NexusInAppMessage({required this.id, required this.layout, this.title, this.body, this.imageUrl, this.backgroundColor, this.textColor, this.buttons = const [], this.triggerType, this.triggerEvent, this.maxDisplays, this.perSession = false, this.design, this.variantId, this.isTest = false})Parameters
Prop
Type
NexusInAppMessage.fromJson
factoryNexusInAppMessage.fromJson(Map<String, dynamic> j)Parameters
Prop
Type
id
fieldfinal String idlayout
fieldfinal String layoutmodal | bottom_sheet | banner_top | banner_bottom | center | fullscreen.
title
fieldfinal String? titlebody
fieldfinal String? bodyimageUrl
fieldfinal String? imageUrlbackgroundColor
fieldfinal String? backgroundColortextColor
fieldfinal String? textColorbuttons
fieldfinal List<NexusInAppButton> buttonstriggerType
fieldfinal String? triggerTypesession_start | event (null = show on fetch).
triggerEvent
fieldfinal String? triggerEventmaxDisplays
fieldfinal int? maxDisplaysperSession
fieldfinal bool perSessiondesign
fieldfinal NexusInAppDesign? designThe look designed in the console. Null for messages made before the
designer — those render from title / body / imageUrl / buttons.
variantId
fieldfinal String? variantIdThe A/B variant this user was assigned (null when the message has no test).
View sourceisTest
fieldfinal bool isTestA "send test" from the console: shown at once, outside triggers and caps, never reported.
View sourceNexusInAppDesign
classThe designed look of an in-app message — built in the Nexus console's
designer and delivered as content.design.
A vertical stack of blocks inside a styled frame. The backend validates
and clamps every value before it is stored, so parsing here is lenient:
anything missing falls back to the console's defaults, and an unknown block
type is skipped rather than failing the whole message.
NexusInAppDesign
constructorconst NexusInAppDesign({required this.blocks, required this.frame, required this.overlayColor, required this.dismissOnBackdropTap, required this.close, required this.animation, required this.autoDismissSeconds, required this.direction})Parameters
Prop
Type
tryParse()
static methodstatic NexusInAppDesign? tryParse(Object? raw)Parameters
Prop
Type
Returns NexusInAppDesign?
blocks
fieldfinal List<NexusInAppBlock> blocksframe
fieldfinal NexusInAppFrame frameoverlayColor
fieldfinal Color overlayColorBackdrop colour, opacity included (modal / sheet / center only).
View sourcedismissOnBackdropTap
fieldfinal bool dismissOnBackdropTapclose
fieldfinal NexusInAppClose closeanimation
fieldfinal String animationfade | slide | zoom | none.
autoDismissSeconds
fieldfinal int autoDismissSeconds0 = stays until dismissed.
View sourcedirection
fieldfinal String directionauto | ltr | rtl.
resolveDirection()
methodTextDirection resolveDirection(TextDirection ambient)auto follows the copy: right-to-left when the first strong character is
Arabic / Hebrew script — the same rule the console preview uses.
Parameters
Prop
Type
Returns TextDirection
NexusInAppFrame
class View sourceNexusInAppFrame
constructorconst NexusInAppFrame({required this.background, required this.background2, required this.backgroundKind, required this.gradientAngle, this.backgroundImageUrl, required this.radius, required this.padding, required this.gap, required this.maxWidth, required this.shadow, required this.borderColor, required this.borderWidth})Parameters
Prop
Type
background
fieldfinal Color backgroundbackground2
fieldfinal Color background2backgroundKind
fieldfinal String backgroundKindsolid | gradient | image.
gradientAngle
fieldfinal double gradientAngleCSS degrees: 180 = top to bottom.
View sourcebackgroundImageUrl
fieldfinal String? backgroundImageUrlradius
fieldfinal double radiuspadding
fieldfinal double paddinggap
fieldfinal double gapmaxWidth
fieldfinal double maxWidthshadow
fieldfinal String shadownone | sm | md | lg.
borderColor
fieldfinal Color borderColorborderWidth
fieldfinal double borderWidthNexusInAppClose
class View sourceNexusInAppClose
constructorconst NexusInAppClose({required this.show, required this.circle, required this.color, required this.atStart})Parameters
Prop
Type
show
fieldfinal bool showcircle
fieldfinal bool circlecolor
fieldfinal Color coloratStart
fieldfinal bool atStartNexusInAppTap
classWhat tapping an image does.
View sourceNexusInAppTap
constructorconst NexusInAppTap({required this.action, this.url, this.event})Parameters
Prop
Type
action
fieldfinal String actiondismiss | url | event.
url
fieldfinal String? urlevent
fieldfinal String? eventNexusInAppBlock
sealed classsealed class NexusInAppBlockOne block of a designed message.
View sourceNexusInAppBlock
constructorconst NexusInAppBlock(this.id)Parameters
Prop
Type
tryParse()
static methodstatic NexusInAppBlock? tryParse(Map<String, dynamic> j)Parameters
Prop
Type
Returns NexusInAppBlock?
id
fieldfinal String idNexusInAppImageBlock
classclass NexusInAppImageBlock extends NexusInAppBlockNexusInAppImageBlock
constructorconst NexusInAppImageBlock(super.id, {required this.url, this.aspectRatio, required this.contain, required this.radius, required this.bleed, this.tap})Parameters
Prop
Type
url
fieldfinal String urlaspectRatio
fieldfinal double? aspectRatioNull = the image's own ratio.
View sourcecontain
fieldfinal bool containradius
fieldfinal double radiusbleed
fieldfinal bool bleedEdge to edge — ignores the frame's padding.
View sourcetap
fieldfinal NexusInAppTap? tapNexusInAppBadgeBlock
classclass NexusInAppBadgeBlock extends NexusInAppBlockNexusInAppBadgeBlock
constructorconst NexusInAppBadgeBlock(super.id, {required this.text, required this.background, required this.foreground, required this.align})Parameters
Prop
Type
text
fieldfinal String textbackground
fieldfinal Color backgroundforeground
fieldfinal Color foregroundalign
fieldfinal String alignNexusInAppHeadingBlock
classclass NexusInAppHeadingBlock extends NexusInAppBlockNexusInAppHeadingBlock
constructorconst NexusInAppHeadingBlock(super.id, {required this.text, required this.size, required this.weight, required this.color, required this.align})Parameters
Prop
Type
text
fieldfinal String textsize
fieldfinal double sizeweight
fieldfinal int weightcolor
fieldfinal Color coloralign
fieldfinal String alignNexusInAppTextBlock
classclass NexusInAppTextBlock extends NexusInAppBlockNexusInAppTextBlock
constructorconst NexusInAppTextBlock(super.id, {required this.text, required this.size, required this.color, required this.align, required this.lineHeight})Parameters
Prop
Type
text
fieldfinal String textsize
fieldfinal double sizecolor
fieldfinal Color coloralign
fieldfinal String alignlineHeight
fieldfinal double lineHeightNexusInAppButtonsBlock
classclass NexusInAppButtonsBlock extends NexusInAppBlockNexusInAppButtonsBlock
constructorconst NexusInAppButtonsBlock(super.id, {required this.row, required this.items})Parameters
Prop
Type
row
fieldfinal bool rowSide by side (true) or stacked full-width (false).
View sourceitems
fieldfinal List<NexusInAppDesignButton> itemsNexusInAppCarouselBlock
classclass NexusInAppCarouselBlock extends NexusInAppBlockA swipeable row of up to 10 cards. Cards share the image shape and type sizes; all are as tall as the tallest, with buttons pinned to the bottom.
View sourceNexusInAppCarouselBlock
constructorconst NexusInAppCarouselBlock(super.id, {required this.cards, required this.aspectRatio, required this.contain, required this.peek, required this.bleed, required this.radius, required this.gap, required this.padding, required this.titleSize, required this.bodySize, required this.showIndicator, required this.indicatorColor, required this.autoplaySeconds})Parameters
Prop
Type
cards
fieldfinal List<NexusInAppCarouselCard> cardsaspectRatio
fieldfinal double aspectRatiocontain
fieldfinal bool containpeek
fieldfinal bool peekShow the edge of the next card (cards are 84% wide).
View sourcebleed
fieldfinal bool bleedEdge to edge — ignores the frame's side padding.
View sourceradius
fieldfinal double radiusgap
fieldfinal double gappadding
fieldfinal double paddingtitleSize
fieldfinal double titleSizebodySize
fieldfinal double bodySizeshowIndicator
fieldfinal bool showIndicatorindicatorColor
fieldfinal Color indicatorColorautoplaySeconds
fieldfinal int autoplaySeconds0 = only by swiping.
View sourceNexusInAppCarouselCard
class View sourceNexusInAppCarouselCard
constructorconst NexusInAppCarouselCard({required this.id, this.imageUrl, required this.title, required this.body, this.button, this.tap, required this.background, required this.titleColor, required this.bodyColor, required this.align})Parameters
Prop
Type
id
fieldfinal String idReported as the click's buttonId when the card itself is tapped.
imageUrl
fieldfinal String? imageUrltitle
fieldfinal String titlebody
fieldfinal String bodybutton
fieldfinal NexusInAppDesignButton? buttontap
fieldfinal NexusInAppTap? tapbackground
fieldfinal Color backgroundtitleColor
fieldfinal Color titleColorbodyColor
fieldfinal Color bodyColoralign
fieldfinal String alignNexusInAppSpacerBlock
classclass NexusInAppSpacerBlock extends NexusInAppBlockNexusInAppSpacerBlock
constructorconst NexusInAppSpacerBlock(super.id, {required this.height})Parameters
Prop
Type
height
fieldfinal double heightNexusInAppDividerBlock
classclass NexusInAppDividerBlock extends NexusInAppBlockNexusInAppDividerBlock
constructorconst NexusInAppDividerBlock(super.id, {required this.color, required this.thickness})Parameters
Prop
Type
color
fieldfinal Color colorthickness
fieldfinal double thicknessNexusInAppDesignButton
class View sourceNexusInAppDesignButton
constructorconst NexusInAppDesignButton({required this.id, required this.text, required this.action, this.url, this.event, this.value, required this.variant, required this.background, required this.foreground, required this.radius})Parameters
Prop
Type
id
fieldfinal String idtext
fieldfinal String textaction
fieldfinal String actiondismiss | url | event | copy.
url
fieldfinal String? urlevent
fieldfinal String? eventvalue
fieldfinal String? valueFor copy: the text put on the clipboard.
variant
fieldfinal String variantfilled | outline | text.
background
fieldfinal Color backgroundFill (filled) or border (outline) colour.
View sourceforeground
fieldfinal Color foregroundLabel colour.
View sourceradius
fieldfinal double radiusNexusInAppView
classclass NexusInAppView extends StatelessWidgetDefault rendering for an in-app message. Bring your own UI via
NexusInAppOverlay(messageBuilder: ...) if you'd rather.
NexusInAppView
constructorconst NexusInAppView({super.key, required this.message, required this.onButton, required this.onDismiss})Parameters
Prop
Type
message
fieldfinal NexusInAppMessage messageonButton
fieldfinal void Function(NexusInAppButton button) onButtononDismiss
fieldfinal VoidCallback onDismissNexusInAppDesignedView
classclass NexusInAppDesignedView extends StatefulWidgetRenders a message designed in the Nexus console: backdrop, placement for the layout, entrance animation, auto-dismiss, and the block stack.
Layout rules match the console preview exactly (padding, gap, edge-to-edge
images, the close-button inset, shadows) — that is what makes the preview
trustworthy. Fills the space it is given; NexusInAppOverlay gives it the
whole screen.
NexusInAppDesignedView
constructorconst NexusInAppDesignedView({super.key, required this.message, required this.design, required this.onButton, required this.onDismiss})Parameters
Prop
Type
message
fieldfinal NexusInAppMessage messagedesign
fieldfinal NexusInAppDesign designonButton
fieldfinal void Function(NexusInAppButton button) onButtononDismiss
fieldfinal VoidCallback onDismissNexusInAppBuilder
typedeftypedef NexusInAppBuilder = Widget Function(BuildContext context, NexusInAppMessage message, void Function(NexusInAppButton button) onButton, VoidCallback onDismiss)Bring your own in-app message UI. Return a widget; drive it with the provided callbacks (button tap / dismiss).
View sourceNexusInAppOverlay
classclass NexusInAppOverlay extends StatefulWidgetHosts the currently-active in-app message above your app. Add it via
MaterialApp.builder so it has a Material/Overlay/MediaQuery ancestor:
MaterialApp(
builder: (context, child) => NexusInAppOverlay(child: child!),
// ...
)NexusInAppOverlay
constructorconst NexusInAppOverlay({super.key, required this.child, this.messageBuilder})Parameters
Prop
Type
child
fieldfinal Widget childmessageBuilder
fieldfinal NexusInAppBuilder? messageBuilder