DefaultLockedWidget class
The built-in fallback UI displayed when a feature is locked behind a higher subscription tier.
Displays a professional locked state with a lock icon, text explaining which tier is required, and an optional upgrade button.
Supports two layout modes:
- Normal (default): A centered column with icon, message, and optional upgrade button. Suitable for larger areas.
- Compact: A single-line row with a small icon and message text. Suitable for use inside lists or constrained spaces.
All colors and text styles are derived from Theme.of(context), ensuring proper appearance in both light and dark themes.
Example:
DefaultLockedWidget(
requiredTier: Tier(id: 'pro', level: 1, label: 'Pro'),
currentTier: Tier(id: 'free', level: 0, label: 'Free'),
onUpgradePressed: () => showPaywall(),
)
Compact mode:
DefaultLockedWidget(
requiredTier: proTier,
currentTier: freeTier,
compact: true,
)
See also:
- SubscriptionGuard, which uses this widget as its default locked UI.
- GuardBehavior.replace, the behavior mode that shows this widget.
- Tier, the model class for the requiredTier and currentTier params.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- DefaultLockedWidget
Constructors
- DefaultLockedWidget({Key? key, required Tier requiredTier, required Tier currentTier, VoidCallback? onUpgradePressed, String? message, IconData icon = Icons.lock_outline, double iconSize = 32.0, Color? iconColor, bool compact = false, double? height})
-
Creates a DefaultLockedWidget showing a locked state for the given tiers.
const
Properties
- compact → bool
-
Whether to use a compact single-line layout.
final
- currentTier → Tier
-
The user's current subscription tier.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
An optional fixed height for the locked widget.
final
- icon → IconData
-
The icon displayed in the locked state.
final
- iconColor → Color?
-
The color of the lock icon.
final
- iconSize → double
-
The size of the lock icon.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- message → String?
-
An optional custom message to display.
final
- onUpgradePressed → VoidCallback?
-
An optional callback invoked when the upgrade button is tapped.
final
- requiredTier → Tier
-
The subscription tier required to unlock the guarded feature.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited