ZenithAuthorizeView class

A declarative Flutter widget that shows different UI depending on whether a ZenithPolicy grants access.

Reactive: when a ZenithNode read inside policy.evaluate or policy.evaluateAsync changes value, the widget automatically rebuilds.

ZenithAuthorizeView(
  policy: exportPolicy,
  authorized: (ctx) => const ExportButton(),
  notAuthorized: (ctx, result) => const PaywallTrigger(),
  authorizing: (ctx) => const ShimmerPlaceholder(),
)
Inheritance

Constructors

ZenithAuthorizeView({Key? key, required ZenithPolicy policy, required Widget authorized(BuildContext context), required Widget notAuthorized(BuildContext context, AuthorizationResult result), Widget authorizing(BuildContext context)?, UserSecurityContext securityContext = const UserSecurityContext()})
Creates a ZenithAuthorizeView.
const
ZenithAuthorizeView.hidden({required ZenithPolicy policy, UserSecurityContext securityContext = const UserSecurityContext(), required Widget authorized(BuildContext context)})
A ZenithAuthorizeView that hides the authorized widget when denied (renders SizedBox.shrink instead of calling notAuthorized).
factory
ZenithAuthorizeView.locked({required ZenithPolicy policy, UserSecurityContext securityContext = const UserSecurityContext(), required Widget authorized(BuildContext context), Widget notAuthorized(BuildContext, AuthorizationResult)?})
A ZenithAuthorizeView that shows a locked icon/overlay when denied.
factory

Properties

authorized → Widget Function(BuildContext context)
Builder rendered when the policy grants access.
final
authorizing → Widget Function(BuildContext context)?
Optional builder rendered while an async policy is resolving.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
notAuthorized → Widget Function(BuildContext context, AuthorizationResult result)
Builder rendered when the policy denies access.
final
policy → ZenithPolicy
The policy to evaluate.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
securityContext → UserSecurityContext
Claims used by requirement policies. Defaults to an anonymous context.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<ZenithAuthorizeView>
Creates the mutable state for this widget at a given location in the tree.
override
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