presentNudge function
Future<void>
presentNudge({
- required BuildContext context,
- required NudgeConfig config,
- EngageActionContext actionContext = EngageActionContext.unknown,
- VariableScope scope = VariableScope.empty,
Presents a NudgeConfig over the app, choosing the bottom-sheet or dialog strategy by its surface. Returns a future that completes when the nudge is dismissed (button action, close affordance, scrim, or drag-down).
Implementation
Future<void> presentNudge({
required BuildContext context,
required NudgeConfig config,
EngageActionContext actionContext = EngageActionContext.unknown,
VariableScope scope = VariableScope.empty,
}) {
final presentation =
_presentations[config.surface.displayType] ?? const BottomSheetPresentation();
// Wrap the content so button taps can hand the host the campaign context, and
// so the renderers can interpolate `{{ placeholder }}` copy against [scope].
return presentation.present(
context: context,
surface: config.surface,
content: EngageActionContextScope(
actionContext: actionContext,
child: VariableScopeProvider(
scope: scope,
child: NudgeView(content: config.content),
),
),
);
}