TrialBanner class
A banner widget that displays the user's trial status and a countdown of remaining days.
Reads trial state from SubscriptionGuardScope and automatically shows or hides based on whether the user is trialing. When the trial is nearing expiration (within urgentThreshold days), the banner switches to an urgent visual style.
Basic usage — shows "X days remaining in your trial":
TrialBanner()
Custom builder for full control:
TrialBanner(
builder: (context, trialInfo) {
return Text('${trialInfo.daysRemaining} days left!');
},
)
With tap handler:
TrialBanner(
onTap: () => showUpgradeDialog(),
)
See also:
- TrialInfo, the model class providing trial state data.
- SubscriptionGuardScope, which exposes the TrialInfo read by this widget.
- SubscriptionGuardProvider, where trial state is configured.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- TrialBanner
Constructors
- TrialBanner({Key? key, Widget builder(BuildContext context, TrialInfo trialInfo)?, VoidCallback? onTap, bool showWhenNotTrialing = false, int urgentThreshold = 3, Color? backgroundColor, Color? urgentBackgroundColor, EdgeInsetsGeometry padding = const EdgeInsets.symmetric(horizontal: 16, vertical: 10), BorderRadius borderRadius = const BorderRadius.all(Radius.circular(8)), EdgeInsetsGeometry margin = const EdgeInsets.symmetric(horizontal: 16, vertical: 8)})
-
Creates a TrialBanner that displays trial status from the nearest
SubscriptionGuardScope.
const
Properties
- backgroundColor → Color?
-
The background color for the normal (non-urgent) state.
final
- borderRadius → BorderRadius
-
Border radius of the banner container.
final
- builder → Widget Function(BuildContext context, TrialInfo trialInfo)?
-
An optional custom builder for full control over the banner content.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- margin → EdgeInsetsGeometry
-
Outer margin around the banner container.
final
- onTap → VoidCallback?
-
An optional callback invoked when the banner is tapped.
final
- padding → EdgeInsetsGeometry
-
Inner padding of the banner container.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showWhenNotTrialing → bool
-
Whether to show the banner when the user is not trialing.
final
- urgentBackgroundColor → Color?
-
The background color for the urgent state (when remaining days are
at or below urgentThreshold).
final
- urgentThreshold → int
-
The number of remaining days at or below which the banner uses
its urgent/warning style.
final
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