Nudge class

Nudge is a centralized SDK manager for handling initialization, user tracking, and event logging within the Nudge SDK.

Constructors

Nudge({required String apiKey, required bool debugMode, required Region region, Function? registerRefreshToken, dynamic registerAuth(String? key)?})
Factory constructor to ensure a single instance of Nudge.
factory

Properties

apiKey String
API key used for authentication.
final
debugMode bool
Determines if the SDK is running in debug mode.
final
externalId String?
External identifier associated with the user.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
region Region
Region
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
uid String?
User's unique identifier.
getter/setter pair

Methods

addLeads({required List<NudgeReferralLead> leads}) Future<void>
Adds referral leads to the native layer.
clearNudges() Future<void>
Removes all nudges for the current screen.
config({required GlobalKey<NavigatorState> navigatorKey, GlobalKey<State<StatefulWidget>>? screenshotKey}) Future<void>
Configures the SDK with a custom navigator key.
getUserDetails() Future<Map<String, dynamic>?>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ping() Future<void>
registerAuth(dynamic callback(String? key)) Future<void>
Sets a callback for handling static keys.
registerRefreshToken(Function callback) Future<void>
Registers a callback for handling refresh tokens.
toString() String
A string representation of this object.
inherited
track({required String event, Map<String, dynamic>? properties}) Future<void>
Tracks an event with optional properties.
userIdentifier({required String? externalId, String? name, String? email, String? phoneNumber, String? referralCode, Map<String, dynamic>? properties}) Future<void>
Identifies the user and updates their attributes.
userSignOut() Future<void>
Logs out the current user from Nudge.

Operators

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

Static Properties

currentContext BuildContext?
Provides access to the current context.
no setter
nudgeAuthKeyCallback ↔ dynamic Function(String? key)?
Callback for getting static key.
getter/setter pair
nudgeNavigatorKey GlobalKey<NavigatorState>
Provides access to the navigator key.
no setter
nudgeRefreshTokenCallback Function?
Callback for refreshing the token.
getter/setter pair
screenshotKey GlobalKey<State<StatefulWidget>>
Provides access to the screenshot key.
no setter
sessionId String?
Unique session identifier.
getter/setter pair
uidG String?
Global unique user identifier.
getter/setter pair
userProps Map<String, dynamic>
Stores user properties for tracking.
getter/setter pair

Static Methods

getInstance() Nudge
Retrieves the current instance of Nudge. Throws an exception if the instance is not initialized.
setContext(BuildContext context) → void
Assign a new context to the current context. Called when the context changes, such as during navigation. Use this method to update the context when navigating to a new screen.