FrequencyManager class
Applies frequency capping for natively-rendered campaigns (nudge, survey, and
guide). Dart port of Android's FrequencyManager: wraps the pure
FrequencyEvaluator with persistence (one FrequencyState per campaignKey)
and pulls the current session id so session windows reset exactly when the
session rotates (cold start / idle timeout / user change).
Persists via PreferencesStore (SharedPreferences), whose reads are
synchronous once initialized — so the route-time gate (isAllowed) stays
synchronous. Writes are fire-and-forget; SharedPreferences updates its
in-memory cache synchronously, so a later read sees the new value at once.
sessionIdProvider returns the current session id; clock is injectable for
tests and defaults to wall-clock.
Constructors
- FrequencyManager(PreferencesStore _store, String? _sessionIdProvider(), {int clock()?})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
blockReason(
CampaignModel campaign) → FrequencySkipReason? -
The reason
campaignis currently blocked, ornullwhen it may show.isAlloweddelegates to this so the gate can log why it dropped — one evaluation, no duplicated logic (mirrors Android'sblockReason). -
isAllowed(
CampaignModel campaign) → bool -
Gate: whether
campaignmay show now. Capping-free policies always pass. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
recordCompleted(
CampaignModel campaign) → void -
Apply the permanent stop on "Digia Experience Completed" (survey + guide),
only when the policy opted into
stopOn: experienceCompleted. -
recordShow(
CampaignModel campaign) → void - Record one show on "Digia Experience Viewed".
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- stopOnExperienceCompleted → const String
-
The only recognised
stopOnvalue — permanently stop on completion.