BiometricGate class

A convenience widget that gates access to its child behind biometric auth.

Wraps BiometricBuilder to provide a simpler API for the common pattern of "show loading -> show child after auth -> show fallback if auth fails".

For more control over auth states, use BiometricBuilder directly.

Example:

BiometricGate(
  shield: shield,
  reason: 'Confirm to view health records',
  userId: currentUser.id,
  child: HealthRecordsScreen(),
  fallbackWidget: (result) => AccessDeniedScreen(result: result),
)
Inheritance

Constructors

BiometricGate({Key? key, required BiometricShieldInterface shield, required Widget child, required String reason, Widget? loadingWidget, Widget fallbackWidget(BiometricResult result)?, void onAuthenticated(BiometricResult result)?, bool reauthOnResume = false, String? userId})
const

Properties

child Widget
The content to show after successful authentication.
final
fallbackWidget Widget Function(BiometricResult result)?
Widget to show if auth fails. Receives the final BiometricResult for context.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loadingWidget Widget?
Widget to show while authentication is in progress. Default: centered CircularProgressIndicator
final
onAuthenticated → void Function(BiometricResult result)?
Called when auth succeeds. Use for side effects (analytics, etc).
final
reason String
Reason shown in the biometric prompt.
final
reauthOnResume bool
If true, re-authenticates when app resumes from background and the session has expired.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shield BiometricShieldInterface
The BiometricShield instance to use. Accepts the interface for DI/testing.
final
userId String?
Override userId for this gate instance.
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