Entitlement class abstract

Flattened entitlement state for the current authenticated user.

Mirrors the JSONB returned by public.current_entitlements(). The typed getters below (canUseTeams, canUseSso, etc.) decode the entitlements map into booleans so UI code doesn't have to remember key names.

Available extensions
Annotations

Constructors

Entitlement({required PlanTier plan, required EntitlementSource source, DateTime? expiresAt, DateTime? trialExpiresAt, DateTime? trialStartedAt, @Default(<String, dynamic>{}) Map<String, dynamic> entitlements, @Default(<String>[]) List<String> grantsApplied, int? aiDailyCap, int? aiWeeklyCap, int? aiTotalCap, @Default(0) int aiBoost})
const
factory
Entitlement.none()
Entitlement for an unauthenticated caller — no access to anything.
factory

Properties

aiBoost → int
Extra AI messages granted via usage_boost grants.
no setterinherited
aiDailyCap → int?
Null = no daily cap for the plan (e.g. unlimited).
no setterinherited
aiTotalCap → int?
Null = no total cap. Non-null only for trial users: total AI messages allowed for the entire trial period (e.g. 50).
no setterinherited
aiWeeklyCap → int?
Null = no weekly cap for the plan.
no setterinherited
canSendAiMessages → bool
Whether new AI messages are currently allowed (caps > 0 or null).
no setter
canUseAnalytics → bool
no setter
canUseApiKeys → bool
no setter
canUseCertifications → bool
no setter
canUseCompliance → bool
no setter
canUseLearningPaths → bool
no setter
canUseScim → bool
no setter
canUseSso → bool
no setter
canUseTeams → bool
no setter
canUseWebhooks → bool
no setter
copyWith → $EntitlementCopyWith<Entitlement>
Create a copy of Entitlement with the given fields replaced by the non-null parameter values.
no setterinherited
entitlements → Map<String, dynamic>
Raw flattened entitlement map from plan_catalog(). Prefer the typed getters below over indexing this directly.
no setterinherited
expiresAt → DateTime?
End of the current subscription period, if any.
no setterinherited
grantsApplied → List<String>
Active admin_grant IDs contributing to this entitlement, for audit.
no setterinherited
hasCertificates → bool
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasUnlimitedDomains → bool
no setter
isExpired → bool
True when the trial has expired and no paid plan took over.
no setter
isOnTrial → bool
True when the user is on trial (not paid, not expired).
no setter
isPaid → bool
True when the user has any paid plan.
no setter
maxDomains → int?
no setter
plan → PlanTier
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
source → EntitlementSource
no setterinherited
trialDaysRemaining → int
Days remaining in the trial (0 if expired or not on trial).
no setter
trialExpiresAt → DateTime?
Computed trial_started_at + 14 days + any extend_trial grants.
no setterinherited
trialStartedAt → DateTime?
Raw trial_started_at from profiles.settings.
no setterinherited

Methods

map<TResult extends Object?>(TResult $default(_Entitlement value)) → TResult

Available on Entitlement, provided by the EntitlementPatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>(TResult? $default(_Entitlement value)?) → TResult?

Available on Entitlement, provided by the EntitlementPatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>(TResult $default(_Entitlement value)?, {required TResult orElse()}) → TResult

Available on Entitlement, provided by the EntitlementPatterns extension

A variant of map that fallback to returning orElse.
maybeWhen<TResult extends Object?>(TResult $default(PlanTier plan, EntitlementSource source, DateTime? expiresAt, DateTime? trialExpiresAt, DateTime? trialStartedAt, Map<String, dynamic> entitlements, List<String> grantsApplied, int? aiDailyCap, int? aiWeeklyCap, int? aiTotalCap, int aiBoost)?, {required TResult orElse()}) → TResult

Available on Entitlement, provided by the EntitlementPatterns extension

A variant of when that fallback to an orElse callback.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
when<TResult extends Object?>(TResult $default(PlanTier plan, EntitlementSource source, DateTime? expiresAt, DateTime? trialExpiresAt, DateTime? trialStartedAt, Map<String, dynamic> entitlements, List<String> grantsApplied, int? aiDailyCap, int? aiWeeklyCap, int? aiTotalCap, int aiBoost)) → TResult

Available on Entitlement, provided by the EntitlementPatterns extension

A switch-like method, using callbacks.
whenOrNull<TResult extends Object?>(TResult? $default(PlanTier plan, EntitlementSource source, DateTime? expiresAt, DateTime? trialExpiresAt, DateTime? trialStartedAt, Map<String, dynamic> entitlements, List<String> grantsApplied, int? aiDailyCap, int? aiWeeklyCap, int? aiTotalCap, int aiBoost)?) → TResult?

Available on Entitlement, provided by the EntitlementPatterns extension

A variant of when that fallback to returning null

Operators

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